-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Applying aws_s3_bucket_policy and aws_s3_bucket_public_access_block at the same time may cause an error #7628
Comments
I am also having issues with this bug: resource "aws_s3_bucket" "this" {
bucket_prefix = "xxxx"
acl = "private"
versioning {
enabled = true
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_s3_bucket_public_access_block" "this" {
bucket = "${aws_s3_bucket.this.bucket}"
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
data "aws_iam_role" "policy_identifiers" {
name = "xxxx"
}
data "aws_iam_policy_document" "s3_bucket_policy_policy" {
version = "2012-10-17"
statement {
effect = "Allow"
actions = ["s3:*"]
resources = [
"${aws_s3_bucket.this.arn}/*",
"${aws_s3_bucket.this.arn}",
]
principals {
type = "AWS"
identifiers = ["${data.aws_iam_role.policy_identifiers.arn}"]
}
}
}
resource "aws_s3_bucket_policy" "this" {
bucket = "${aws_s3_bucket.this.bucket}"
policy = "${data.aws_iam_policy_document.s3_bucket_policy_policy.json}"
}
|
Using resource "aws_s3_bucket_policy" "this" {
depends_on = ["aws_s3_bucket_public_access_block.this"] This worked for me. |
I think that |
Either that or sort out planned API calls to S3 so that they happen in sequence. |
Some sort ordering seems needed, a related issue is that if you have AWS Guardduty enabled and you terraform destroy an s3 bucket you will get a security alert that the "Block public access policies" have been removed because they are removed before the bucket is removed rather than just destroying the bucket first. |
|
I was doing it wrong, I had added the |
Still experiencing this as of v0.12.28. |
IMO documenting the use of |
It seems this is also an issue when managing aws_s3_bucket_notification resources. |
There seems to be an eventual consistency component along with the serialization aspect of these requests. In one case, the request to PutBucketVersioning went out immediately after the response from PutBucketTagging came back and the bucket hadn't resolved its state yet.
|
We've been intermittently experiencing a variety of
In our case, we typically aren't creating In each of the cases we've triaged, the S3 bucket can eventually be created and set with the desired configuration if enough retries are attempted. Generally, a single retry within a minute of the first failed try has been sufficient. In some cases, though, we've had wait for up to 45 minutes before a retry succeeds. From descriptions I've seen of this error, it sounds like a common condition that would trigger this is recreating an S3 bucket which has just just been deleted or hitting a soft limit on the number of S3 buckets in an account. I don't believe either has been true in our case, though, since the number of buckets have been well under our account limit around the time of some failures and the buckets we're creating are most often unique. In the implementation the For the S3 server side encryption configuration one, we had put up a PR, which would add retries for 409 errors, although that PR has been up for over 10 months now without any attention. Perhaps it would make sense to add similar retries for each of the S3 API calls that the AWS provider could make. Unfortunately, though, the retry timeout might need to be very high (45 minutes or longer?) in order to reliably overcome the errors. It would be nice to figure out the sequences of events from interactions with the AWS S3 API that produce these errors so that we could avoid them (either in Terraform code or, at least where possible, within the Terraform AWS provider). |
This is also experienced with the |
You can't modify an S3 bucket's policy & public access block at the same time, AWS API will complain: OperationAborted: A conflicting conditional operation is currently in progress against this resource Serialise operations to the origin bucket so we don't run into this error. The suggested fix is from hashicorp/terraform-provider-aws#7628
Running into this as well, with bucket policies (block non-SSL traffic) and public-access-block on the same s3 bucket. I agree with the desire that TF should backoff and retry on this error message. |
The same with |
I am also facing this issue |
+1 to the list. It looks like TF should better re-try on |
Without this depency, it may cause the following error: │ Error: Error putting S3 policy: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. hashicorp/terraform-provider-aws#7628
Without this depency, it may cause the following error: │ Error: Error putting S3 policy: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. hashicorp/terraform-provider-aws#7628
Without this depency, it may cause the following error: Error putting S3 policy: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. hashicorp/terraform-provider-aws#7628
Without this depency, it may cause the following error: Error putting S3 policy: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. hashicorp/terraform-provider-aws#7628
Without this depency, it may cause the following error: Error putting S3 policy: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. hashicorp/terraform-provider-aws#7628
Without this depency, it may cause the following error: Error putting S3 policy: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. hashicorp/terraform-provider-aws#7628
seeing this on terraform |
Seeing this frequently on destruction of a bucket with a bucket notification configuration. AWS Provider 3.62.0
|
I was experiencing the
Makes sense when I think about it...the polciy needs to be created before the public access block is applied. |
Hi all 👋 Just letting you know that this is issue is featured on this quarters roadmap. If a PR exists to close the issue a maintainer will review and either make changes directly, or work with the original author to get the contribution merged. If you have written a PR to resolve the issue please ensure the "Allow edits from maintainers" box is checked. Thanks for your patience and we are looking forward to getting this merged soon! |
Getting the same behaviour when processing a parallel foreach from a map of account names to account ids: "Error: error putting S3 Bucket Notification Configuration: OperationAborted: A conflicting conditional operation is currently in progress against this resource. Please try again. Any possible workaround, some kind of time_sleep as I can't see it?
|
This should be resolved with #12949. However, since this issue is tricky to test, please open a new issue (and reference this issue) if you continue to see problems! |
Do we have an ETA for when 3.67.0 will be released? We are facing this issue while building our production environment. |
This functionality has been released in v3.67.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! |
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. |
Terraform Version
Affected Resource(s)
Terraform Configuration
Debug Output
Panic Output
No panic
Expected Behavior
No error
Actual Behavior
Got an error
Steps to Reproduce
terraform apply.
Important Factoids
Success and failure depend on timing.
I tried it a couple of times, but in my environment, there are fewer cases without the error.
References
Although the types of resources are different, calling S3 API in parallel to the same bucket may cause this error.
The text was updated successfully, but these errors were encountered: