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