Terraform-provider-aws: Add new resource for s3 bucket lifecycle configuration

Created on 17 Oct 2018  路  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 "me too" comments, 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

Description

Allow independent systems manage different parts of an s3 bucket configuration.
System A - manages lifecycle of bucket
System B - manages lifecycle of bucket lifecycle configuration
Both systems use terraform modules to isolate change scope.

New or Affected Resource(s)

  • aws_s3_bucket (modifies)
  • aws_s3_bucket_lifecycle_configuration (new)

Potential Terraform Configuration

resource "aws_s3_bucket" "b" {
  bucket = "my-tf-test-bucket"
  acl    = "private"

  tags {
    Name        = "My Bucket"
    Environment = "Dev"
  }
}

resource "aws_s3_bucket_lifecycle_configuration" {
  bucket = "${aws_s3_bucket.b.id}"

  rule  {
    id      = "log"
    enabled = true
    prefix  = "log/"

    tags {
      "rule"      = "log"
      "autoclean" = "true"
    }

    transition {
      days          = 15
      storage_class = "ONEZONE_IA"
    }

    transition {
      days          = 30
      storage_class = "STANDARD_IA"
    }

    transition {
      days          = 60
      storage_class = "GLACIER"
    }

    expiration {
      days = 90
    }
  }

  rule {
    id      = "tmp"
    prefix  = "tmp/"
    enabled = true

    expiration {
      date = "2016-01-12"
    }
  }
}


References

new-resource servics3

Most helpful comment

Would this make more sense as an addition to the aws_s3_bucket_object resource? That is an already existing location that would make sense to attach lifecycle rules to and is already composable within the existing terraform s3 resources

All 9 comments

Would this make more sense as an addition to the aws_s3_bucket_object resource? That is an already existing location that would make sense to attach lifecycle rules to and is already composable within the existing terraform s3 resources

Has there been any movement on this? The lack of this feature is actually causing me to consider using a different tool for s3 provisioning.

I would like to see this as well. It's making my life very complicated right now.

Yes I need this as well

Another vote for this feature.

Another vote

+1

+1

+1, this is helpful, if we have a module for S3 and if we need to extend.

As of now as this does not exist, have to use custom resources for same and add lifecycle policy

Was this page helpful?
0 / 5 - 0 ratings