-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
S3 bucket slow to delete when destroyed during an apply #12146
Comments
@MrAtoms Of what order of magnitude is the number of objects (including all versions) in the bucket? |
@ewbankkit If I recall, the buckets that were destroyed had hundreds of thousands of objects in them. |
We're encountering this as well
|
I'm seeing this issue in 0.12.21. The order of magnitude of the objects in the bucket is hundreds of thousands. Deleting the bucket through the web console works just fine, but Terraform just says "Still destroying..." forever. |
In my case the issue can be replicated with just 5000 objects in bucket without versioning enabled. Took around 30 minutes. Used 0.12.21 terraform and AWS terraform provider v2.49.0 |
I have had this happen with ~100 items ina bucket. |
The performance is terrible especially when deleting a bucket geographically located across the world with a higher latency. It's deleting about 40 objects per minute if deleting a Sydney bucket from London. |
Same problem here. While deleting in UI, we can see progress. So, would be great to see some sort of progress indicator here as well. Terraform v0.12.29
|
Hi, |
This problem is still available! Does anyone know how the current state? |
We found a really simple workaround that I have documented here: https://gist.github.com/bassmanitram/53a57988d9f4e4a2ffc94aed789bbf9e When testing with a bucket containing 190,000 objects, this technique deleted the content and the bucket in about 30 minutes. Without this workaround, the terraform destroy command was still running 12 hours later with still over 75000 objects left in the bucket (I got bored waiting and deleted them via the AWS S3 console just to put TF out of its misery). NOTE that this WON'T work for buckets with object versioning enabled since the CLI s3 rm command simply places a deleted marker in the object history rather than actually getting rid of the object. |
This issue first appears in v2.29.0 and looks related to the changes in #9942 - where The changelog for v2.29.0 doesn't suggest there's any change in behaviour for This issue can even be seen with as few as 200 objects in a bucket. terraform-provider-aws v2.28.1 takes ~11 seconds to Debug logging also shows v2.28.1 is deleting multiple objects in a single s3/DeleteObjects API call:
Whereas, terraform-provider-aws v2.29.0 is seen deleting single objects in multiple s3/DeleteObjects API call (there's 200 s3/DeleteObjects API calls in the 200 objects example):
There doesn't seem to be an elegant workaround for this issue and its limiting our ability to upgrade. |
This has been a constant thorn in my side during development of an environment, if left overnight (and the bucket is receiving VPC flow logs, or access logs of other buckets) then the delete/teardown will take hours. Generally this is in the 20k objects region including versioned files and it'll take even longer if the bucket has an object_lock set to GOVERNANCE. To find the active items, we use the ListObjectsV2 API call (iterating over blocks of 1000 items), and when deleting them we only specify the key in the list of ObjectIdentifier structs to DeleteObjects API call (and providing the BypassGovernanceRetention flag in the delete if object lock is enabled in the bucket). After those have been deleted in batches of 1000 Then this process is repeated for the DeleteMarkers and Versions lists in the ListObjectVersionsOutput response to the ListObjectVersions PAI call, again using blocks of 1000 objects. You probably also want to deal with the multi-part uploads (not in use in our case). |
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! |
@ewbankkit are you working on this atm? |
@ojongerius Yes, it's in my queue. |
This functionality has been released in v4.9.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. |
Community Note
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
S3 bucket destroyed in a timely manner (e.g., within minutes)
Actual Behavior
S3 bucket takes multiple hours to destroy
Steps to Reproduce
terraform apply
Important Factoids
terraform destroy
seem to work as expected.The text was updated successfully, but these errors were encountered: