Skip to content

Commit 83d546e

Browse files
committed
feat(csp): add CloudFront response headers policy with Content-Security-Policy
- introduce aws_cloudfront_response_headers_policy resource - define CSP allowing required external scripts (Google Ads, CDNJS)
1 parent 2c8205d commit 83d546e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

terraform/website/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ resource "aws_s3_bucket_website_configuration" "bucket" {
9090
])
9191
}
9292

93+
resource "aws_cloudfront_response_headers_policy" "csp" {
94+
name = "colorcop-csp-policy"
95+
96+
security_headers_config {
97+
content_security_policy {
98+
override = true
99+
content_security_policy = "default-src 'self'; script-src 'self' 'unsafe-eval' https://pagead2.googlesyndication.com https://googleads.g.doubleclick.net https://cdnjs.cloudflare.com; style-src 'self' https://cdnjs.cloudflare.com 'unsafe-inline'; img-src 'self' data: https://pagead2.googlesyndication.com https://googleads.g.doubleclick.net;"
100+
}
101+
}
102+
}
103+
93104
resource "aws_cloudfront_distribution" "distribution" {
94105
aliases = [local.www_domain, var.domain]
95106
comment = "Cloudfront distribution for ${var.domain}"

0 commit comments

Comments
 (0)