Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workaround for empty logging race condition #260

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions infra/modules/terraform-backend-s3/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,29 @@ resource "aws_s3_bucket_policy" "tf_log" {
policy = data.aws_iam_policy_document.tf_log.json
}

# This is a workaround to a race condition that seems to have been recently introduced
# by AWS S3 and at the time of writing (2023-05-09) has yet to be resolved.
# See https:/hashicorp/terraform-provider-aws/issues/31139 for more details
# about the issue.
# There is an outstanding PR in the Terraform AWS provider created on Apr 24, 2023 that
# may resolve this issue: https:/hashicorp/terraform-provider-aws/pull/30916
resource "null_resource" "logging_empty_output_workaround" {
provisioner "local-exec" {
command = "sleep 15"
}

triggers = {
bucket = aws_s3_bucket.tf_state.bucket
}

depends_on = [aws_s3_bucket.tf_state]
}

resource "aws_s3_bucket_logging" "tf_state" {
bucket = aws_s3_bucket.tf_state.id

target_bucket = aws_s3_bucket.tf_log.id
target_prefix = "logs/${aws_s3_bucket.tf_state.bucket}/"

depends_on = [null_resource.logging_empty_output_workaround]
}