Skip to content

Commit 0f9f60c

Browse files
chore: Updated S3 bucket policy for OAC in the complete example (#105)
Co-authored-by: Anton Babenko <[email protected]>
1 parent 27fe8d5 commit 0f9f60c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

examples/complete/main.tf

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,8 @@ module "records" {
290290
]
291291
}
292292

293-
###########################
294-
# Origin Access Identities
295-
###########################
296293
data "aws_iam_policy_document" "s3_policy" {
294+
# Origin Access Identities
297295
statement {
298296
actions = ["s3:GetObject"]
299297
resources = ["${module.s3_one.s3_bucket_arn}/static/*"]
@@ -303,6 +301,23 @@ data "aws_iam_policy_document" "s3_policy" {
303301
identifiers = module.cloudfront.cloudfront_origin_access_identity_iam_arns
304302
}
305303
}
304+
305+
# Origin Access Controls
306+
statement {
307+
actions = ["s3:GetObject"]
308+
resources = ["${module.s3_one.s3_bucket_arn}/static/*"]
309+
310+
principals {
311+
type = "Service"
312+
identifiers = ["cloudfront.amazonaws.com"]
313+
}
314+
315+
condition {
316+
test = "StringEquals"
317+
variable = "aws:SourceArn"
318+
values = [module.cloudfront.cloudfront_distribution_arn]
319+
}
320+
}
306321
}
307322

308323
resource "aws_s3_bucket_policy" "bucket_policy" {

0 commit comments

Comments
 (0)