Open
Description
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
- Using aws provider v4.67.0
- 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
- Terraform v1.5.7
- Use the code above - change the bucket name
- Have a default Lifecycle policy created when a new S3 bucket is created (from the AWS organization)
- 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
- The same terraform code works (without timeout error) for AWS provider version v4.67.0
- 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.
- 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
Would you like to implement a fix?
None