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

[Bug]: Intermittent failure when creating s3 bucket policy on clean install #33569

Closed
acaban-nuharbor opened this issue Sep 21, 2023 · 4 comments · Fixed by #33537
Closed

[Bug]: Intermittent failure when creating s3 bucket policy on clean install #33569

acaban-nuharbor opened this issue Sep 21, 2023 · 4 comments · Fixed by #33537
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Milestone

Comments

@acaban-nuharbor
Copy link

acaban-nuharbor commented Sep 21, 2023

Terraform Core Version

1.5.7

AWS Provider Version

5.17.0

Affected Resource(s)

  • aws_s3_bucket_policy

Expected Behavior

Expect that bucket policy is created.

Actual Behavior

Intermittent error on a fresh deployment: Error reading S3 Bucket

Relevant Error/Panic Output Snippet

╷
│ Error: reading S3 Bucket (XXXXXXXXXX-logs) Policy: couldn't find resource

│   with aws_s3_bucket_policy.audit_log_allow_access,
│   on s3-log-bucket.tf line 33, in resource "aws_s3_bucket_policy" "audit_log_allow_access":
│   33: resource "aws_s3_bucket_policy" "audit_log_allow_access" {


ERRO[0275] Terraform invocation failed in .terragrunt-cache/WRdDFKR7y7FA94O9ukP0G38jDGY/vMlrMTYqfU9GCE4MX0HFNYBoDYE/modules/project  prefix=[XXXXXX] 
ERRO[0275] 1 error occurred:
        * [.terragrunt-cache/WRdDFKR7y7FA94O9ukP0G38jDGY/vMlrMTYqfU9GCE4MX0HFNYBoDYE/modules/project] exit status 1

Terraform Configuration Files

resource "aws_s3_bucket" "log_bucket" {
  bucket        = "${var.name_prefix}-${local.account_id}-logs"
  force_destroy = true
}

data "aws_iam_policy_document" "s3_audit_log_allow_access" {
  # ...
}

resource "aws_s3_bucket_policy" "audit_log_allow_access" {
  bucket = aws_s3_bucket.log_bucket.id
  policy = data.aws_iam_policy_document.s3_audit_log_allow_access.json
}

Steps to Reproduce

On a fresh account, run the above terraform script. The script intermittently fails with above error. Adding a sleep between S3 creation and Policy creation sometimes helps.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@acaban-nuharbor acaban-nuharbor added the bug Addresses a defect in current functionality. label Sep 21, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/iam Issues and PRs that pertain to the iam service. service/s3 Issues and PRs that pertain to the s3 service. labels Sep 21, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 21, 2023
@universam1
Copy link

universam1 commented Sep 22, 2023

same problem here with provider 5.17.0
@ewbankkit could it be related to #33531 ?

@ewbankkit ewbankkit removed service/iam Issues and PRs that pertain to the iam service. needs-triage Waiting for first response or review from a maintainer. labels Sep 22, 2023
@github-actions github-actions bot added this to the v5.19.0 milestone Sep 22, 2023
@hashicorp hashicorp deleted a comment from github-actions bot Sep 26, 2023
@github-actions
Copy link

This functionality has been released in v5.19.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
3 participants