Skip to content

Commit fa19074

Browse files
Jean717pcageyvsemantic-release-bot
authored
fix: Fixed Bucket Policy chain dependency with Public Access Block (#227)
Co-authored-by: Vladimir Samoylov <[email protected]> Co-authored-by: semantic-release-bot <[email protected]>
1 parent 3caf180 commit fa19074

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

main.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,16 @@ resource "aws_s3_bucket_replication_configuration" "this" {
512512
resource "aws_s3_bucket_policy" "this" {
513513
count = local.create_bucket && local.attach_policy ? 1 : 0
514514

515+
# Chain resources (s3_bucket -> s3_bucket_public_access_block -> s3_bucket_policy )
516+
# to prevent "A conflicting conditional operation is currently in progress against this resource."
517+
# Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628
518+
515519
bucket = aws_s3_bucket.this[0].id
516520
policy = data.aws_iam_policy_document.combined[0].json
521+
522+
depends_on = [
523+
aws_s3_bucket_public_access_block.this
524+
]
517525
}
518526

519527
data "aws_iam_policy_document" "combined" {
@@ -789,11 +797,7 @@ data "aws_iam_policy_document" "require_latest_tls" {
789797
resource "aws_s3_bucket_public_access_block" "this" {
790798
count = local.create_bucket && var.attach_public_policy ? 1 : 0
791799

792-
# Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)
793-
# to prevent "A conflicting conditional operation is currently in progress against this resource."
794-
# Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628
795-
796-
bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id
800+
bucket = aws_s3_bucket.this[0].id
797801

798802
block_public_acls = var.block_public_acls
799803
block_public_policy = var.block_public_policy

0 commit comments

Comments
 (0)