terraform-aws-modules / terraform-aws-s3-bucket

Terraform module to create AWS S3 resources 🇺🇦

Home Page:https://registry.terraform.io/modules/terraform-aws-modules/s3-bucket/aws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add ability to set terraform lifecyle parameters for the S3 bucket such as `prevent_destroy`

gwvandesteeg opened this issue · comments

Is your request related to a new offering from AWS?

  • No, default lifecycle meta argument in all recent terraform versions

Is your request related to a problem? Please describe.

Upgrade of this module resulted in an S3 bucket being deleted and re-created destroying all content

Describe the solution you'd like.

Add the ability to enable/disable the prevent_destroy and create_before_destroy lifecycle meta arguments

Describe alternatives you've considered.

It is an additional step in the systems to prevent S3 bucket deletion, as well as using SCP's and IAM changes.

Additional context

Should be simple to add to the input

variable "create_before_destroy" {
  type = bool
  default = false
}

variable "prevent_destroy" {
  type = bool
  default = false
}

then add in the resource "aws_s3_bucket" "this"

lifecycle {
  prevent_destroy = var.prevent_destroy
  create_before_destroy = var.create_before_destroy
}

That should roughly do what is needed.

Terraform doesn't allow the use of variables inside of lifecycle blocks.

I'm going to lock this issue because it has been closed for 30 days . This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.