Skip to content

Commit f6c3ce2

Browse files
authored
Allow creating a policy for an existing S3 bucket (#154)
1 parent d378e4b commit f6c3ce2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ data "aws_iam_policy_document" "origin_website" {
8787
}
8888

8989
resource "aws_s3_bucket_policy" "default" {
90-
count = (module.this.enabled && (! local.using_existing_origin || var.override_origin_bucket_policy)) ? 1 : 0
91-
bucket = join("", aws_s3_bucket.origin.*.bucket)
90+
count = (module.this.enabled && (! local.using_existing_origin || var.override_origin_bucket_policy)) ? 1 : 0
91+
bucket = join("", local.using_existing_origin
92+
? data.aws_s3_bucket.selected.*.bucket # Existing origin S3 bucket
93+
: aws_s3_bucket.origin.*.bucket # Origin S3 bucket this module manages
94+
)
9295
policy = local.iam_policy_document
9396
}
9497

0 commit comments

Comments
 (0)