1

I am using terraform version 0.14 and AWS provider 4.0.0

I am trying to add two lifecycle rules to the same bucket. My terraform code is:

resource "aws_s3_bucket_lifecycle_configuration" "testing_lifecycle_1" {
  bucket = aws_s3_bucket.testing.id

  rule {
    id     = "delete_old_versions"
    prefix = ""
    expiration {
      expired_object_delete_marker = true
    }
    noncurrent_version_expiration {
      noncurrent_days = 1
    }
    status = "Enabled"
  }
}

resource "aws_s3_bucket_lifecycle_configuration" "testing_lifecycle_2" {
  bucket = aws_s3_bucket.testing.id

  rule {
    id     = "delete_old_inventory"
    prefix = "inventory/"
    expiration {
      days = 7
    }
    status = "Enabled"
  }
}

When i try and apply this, testing_lifecycle_1 gets created but if can't create testing_lifecycle_2, it will timeout trying to create it. I get the following error message

Error: error waiting for S3 Lifecycle Configuration for bucket (NAME_OF_BUCKET) to reach expected rules status after update: timeout while waiting for state to become 'READY' (last state: 'NOT_READY', timeout: 3m0s)

I've looked into increasing timeout but that timeout function isn't supported for this resource. But it shouldn't be taking over 3 minutes to make the 2nd rule anyway

Anyone come across this before?

Marko E
  • 13,362
  • 2
  • 19
  • 28
polo
  • 155
  • 4
  • 11

1 Answers1

3

As per the documentation:

S3 Buckets only support a single lifecycle configuration. Declaring multiple aws_s3_bucket_lifecycle_configuration resources to the same S3 Bucket will cause a perpetual difference in configuration.

enter image description here

Marko E
  • 13,362
  • 2
  • 19
  • 28
  • thank you so much, can't believe i missed that – polo Mar 08 '23 at 15:44
  • Here is how you can accept an answer if it was helpful: https://meta.stackexchange.com/questions/86978/how-do-i-accept-an-answer-on-stack-overflow/86979#86979. – Marko E Mar 09 '23 at 08:18