tflint-ruleset-google
tflint-ruleset-google copied to clipboard
[proposal] Warn google_bigtable_instance without prevent_destroy
See https://www.terraform.io/docs/providers/google/r/bigtable_instance.html
Note: It is strongly recommended to set lifecycle { prevent_destroy = true } on instances in order to prevent accidental data loss. See Terraform docs for more information on lifecycle parameters.
Love the idea of encouraging explicit prevent_destroy values for stateful resource types: https://github.com/terraform-linters/tflint-ruleset-google/issues/25, https://github.com/terraform-linters/tflint-ruleset-google/issues/30, https://github.com/terraform-linters/tflint-ruleset-google/issues/37, https://github.com/hashicorp/terraform/issues/24658, https://github.com/aws-cloudformation/cfn-lint/pull/1232
Few thoughts:
- One rule could cover the indefinitely expanding list of resource types, here's a similar expanding list for a similar rule: https://github.com/aws-cloudformation/cfn-lint/blob/main/src/cfnlint/data/AdditionalSpecs/StatefulResources.json
- Useful for other providers like
awsandazurermas well - Don't think we should enforce a certain value of
prevent_destroyitself, think we should just encourage explicitness alone
prevent_destroy also mentioned in https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk
The reason I haven't worked on this is because I was worried that declaring a prevent_destroy for a test instance, could seem redundant. I want to avoid warnings for code that works correctly as much as possible.
However, I agree that it is good practice to always declare prevent_destroy so that it can be explicitly declared whether it is for testing that may be deleted or data that should not be deleted.