Skip to content

[Bug]: aws_s3_bucket_lifecycle_configuration times out when another Lifecycle config is present. #41199

Open
@Tesseract99

Description

@Tesseract99

Terraform Core Version

1.5.7

AWS Provider Version

5.84.0

Affected Resource(s)

aws v5.84.0 - aws_s3_bucket_lifecycle_configuration

Expected Behavior

aws_s3_bucket_lifecycle_configuration.my_bucket creation should have completed without any error.

Infact, same code works fine when

  1. Using aws provider v4.67.0
  2. Or, When I manually delete the additional Lifecycle that get autocreated by the AWS organization for all new S3 buckets - while the creation is in progress. (before timeout)

Actual Behavior

Terraform apply fails with the below error. But, the S3 bucket and even the Life Cycle configuration would have been created successfully if I check from the AWS console.

 aws_s3_bucket_lifecycle_configuration.my_bucket_cfg: Still creating... [3m0s elapsed]
 ╷
 │ Error: waiting for S3 Bucket Lifecycle Configuration (my-bucket-name) create: timeout while waiting for state to become 'true' (last state: 'false', timeout: 3m0s)
 │ 
 │   with aws_s3_bucket_lifecycle_configuration.my_bucket_cfg,
 │   on main.tf line 37, in resource "aws_s3_bucket_lifecycle_configuration" "my_bucket_cfg":
 │   37: resource "aws_s3_bucket_lifecycle_configuration" "my_bucket_cfg" {

Relevant Error/Panic Output Snippet

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5"
    }
  }
}

##bucket
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-bucket-name"
  force_destroy = "true"

}

## versioning
resource "aws_s3_bucket_versioning" "my_bucket_vsn" {
  bucket = aws_s3_bucket.my_bucket.id
  versioning_configuration {
    status = "Enabled"
  }
}


##lifecycle
resource "aws_s3_bucket_lifecycle_configuration" "my_bucket_cfg" {
  bucket = aws_s3_bucket.my_bucket.id
  depends_on = [aws_s3_bucket_versioning.my_bucket_vsn]

  rule {
    id      = "delete"
    status  = "Enabled"
  filter {
    prefix  = "/"
    }
    expiration {
      days = "7"
    }
  }

}

Steps to Reproduce

  1. Terraform v1.5.7
  2. Use the code above - change the bucket name
  3. Have a default Lifecycle policy created when a new S3 bucket is created (from the AWS organization)
  4. terraform apply

Debug Output

HTTP Response Received: tf_provider_addr=registry.terraform.io/hashicorp/aws tf_resource_type=aws_s3_bucket_lifecycle_configuration  rpc.system=aws-api tf_aws.sdk=aws-sdk-go-v2 http.response.header.x_amz_transition_default_minimum_object_size=all_storage_classes_128K http.status_code=200 
http.response.body="http.response.body="
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration
	xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
	<Rule>
		<ID>delete</ID>
		<Filter>
			<Prefix>/</Prefix>
		</Filter>
		<Status>Enabled</Status>
		<Expiration>
			<Days>7</Days>
		</Expiration>
	</Rule>
<Rule>
organization default rule (auto added)
</Rule>
</LifecycleConfiguration>

Panic Output

No response

Important Factoids

  1. The same terraform code works (without timeout error) for AWS provider version v4.67.0
  2. During the Life Cycle creation process, If I manually delete the Additional S3 Lifecycle that gets auto added to all new S3 bucket by AWS org, the creation completes without any time out error.
  3. So, I'm suspecting - it has to do with the Organization LifeCycle that get added to any new S3 bucket is "confusing" the terraform APIs. But, then the same code works fine for provider v4.67 - so has some terraform API changed for 5.8 ?

References

#25939

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.needs-triageWaiting for first response or review from a maintainer.service/s3Issues and PRs that pertain to the s3 service.waiting-responseMaintainers are waiting on response from community or contributor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions