Open Nold360 opened 1 year ago
Hi, @Nold360. Thanks for sharing! Can you open a PR with the change you described? That would help a lot, considering maintainers are mostly unavailable these days. We're also looking for more people to help maintain the provider, in case you're interested!
I believe that this feature of terraform is already working as expected.
resource "minio_s3_bucket" "test" {
bucket = "test"
lifecycle {
prevent_destroy = true
}
}
and destroying it again will fail:
$ terraform destroy -target minio_s3_bucket.test
minio_s3_bucket.test3: Refreshing state... [id=test]
╷
│ Warning: Resource targeting is in effect
│
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current
│ configuration.
│
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform
│ specifically suggests to use it as part of an error message.
╵
╷
│ Error: Instance cannot be destroyed
│
│ on test.tf line 5:
│ 5: resource "minio_s3_bucket" "test" {
│
│ Resource minio_s3_bucket.test has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. To avoid this error and continue with the
│ plan, either disable lifecycle.prevent_destroy or reduce the scope of the plan using the -target flag.
Is it possible that you are confusing this with commenting out/removing the configuration completely, @Nold360 ? Because in that case there is no protection by terraform - but that is expected, see https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#prevent_destroy.
Description
When creating a bucket & then running
terraform destroy
the bucket will get deleted.I would like to prevent the bucket from getting destroyed, even tho everything else (user, policy, ...) are getting destroyed. Sadly this is not possible with terraforms
prevent_destroy
lifecycle option.So adding a
prevent_destroy
option to the bucket resource would be sufficient.Steps to Reproduce
Expected behavior: Bucket gets destoyed
Wanted / Optional behavior: Bucket doesn't get destroyed, but everything else