Terraform-provider-aws: S3 bucket slow to delete when destroyed during an apply

Created on 24 Feb 2020  路  9Comments  路  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

  • Terraform version: 0.12.9
  • AWS provider version: 2.42

Affected Resource(s)

  • aws_s3_bucket

Terraform Configuration Files

resource "aws_s3_bucket" "cdn_logs_bucket" {
  bucket        = "cdn.logs.${local.fqdn}"
  acl           = "private"
  force_destroy = "true"
  tags          = "${var.tags}"

  server_side_encryption_configuration {
    rule {
      apply_server_side_encryption_by_default {
        sse_algorithm = "AES256"
      }
    }
  }
}

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

  1. Create an S3 bucket via Terraform
  2. terraform apply
  3. Put some objects in the bucket
  4. Remove S3 bucket from Terraform

Important Factoids

  • I've encountered this a few times and was able to delete the S3 bucket manually via the AWS console before Terraform finished deleting it.
  • S3 bucket destroys during a terraform destroy seem to work as expected.
needs-triage servics3

Most helpful comment

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

All 9 comments

@mratoms Of what order of magnitude is the number of objects (including all versions) in the bucket?
Internally the provider ends up listing all the object versions in a bucket and deleting them one at a time when the bucket is deleted.
We could look at deleting objects in batches via the DeleteObjects API.

@ewbankkit If I recall, the buckets that were destroyed had hundreds of thousands of objects in them.

We're encountering this as well

aws_s3_bucket.account_logging_s3_pr[0]: Still destroying... [id=bucketname, 402h21m30s elapsed]

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.
module.aws_s3_bucket_NAME.aws_s3_bucket.this[0]: Still destroying... [id=NAME, 58m51s elapsed]
source = "terraform-aws-modules/s3-bucket/aws"
version = "1.9.0"

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

  • provider.aws v2.61.0

Hi,
Was there any update on this? I haven't tried the new version of the provider but this is really blocking us to migrate to new version and try out the AWS features released in newer versions.

Was this page helpful?
0 / 5 - 0 ratings