tflint-ruleset-google icon indicating copy to clipboard operation
tflint-ruleset-google copied to clipboard

[proposal] Warn google_bigtable_instance without prevent_destroy

Open wata727 opened this issue 5 years ago • 3 comments
trafficstars

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.

wata727 avatar Sep 26 '20 13:09 wata727

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:

  1. 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
  2. Useful for other providers like aws and azurerm as well
  3. Don't think we should enforce a certain value of prevent_destroy itself, think we should just encourage explicitness alone

PatMyron avatar Feb 02 '22 06:02 PatMyron

prevent_destroy also mentioned in https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk

PatMyron avatar Feb 02 '22 18:02 PatMyron

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.

wata727 avatar Feb 03 '22 14:02 wata727