06
Oct
The naming convention for our Terraform environment was one of our favorites because it clearly indicated the declaration location. So, I built my favorite terraform coding rule via tflint. here The rule is very simple.Every resource must defined in the its resource-name file. variable,locals,output,provider,module are all defined in variable.tf,locals.tf,output.tf,provider.tf,module.tf data are all defined in data_<data_type>.tf resource are all defined in <resource_type>.tf Installation .tflint.hcl plugin "file-name-is-resource-name" {enabled = truesource = "github.com/shoppingjaws/tflint-ruleset-file-name-is-resource-name"version = "1.0.0"} Enter fullscreen mode Exit fullscreen mode Settings File name rules that should be defined can be overwritten rule "file_name_is_resource_name" {enabled = truemodule_file_name_pattern = "^main.tf$"variable_file_name_pattern= "^variable.tf$"locals_file_name_pattern= "^locals.tf$"provider_file_name_pattern= "^provider.tf$"output_file_name_pattern= "^output.tf$"module_file_name_pattern=…