The TerraformCodeReviewer extension for Visual Studio Code helps to review Terraform code generated for Azure infrastructure. It checks for various best practices and common issues such as missing tags, hardcoded values, and missing validations for variables in Terraform configurations.
Features
Tag Validation: Ensures that all resources in your Terraform code have tags associated with them.
Hardcoded Values: Scans your Terraform code for hardcoded values in parameters like name, resource_group_name, and location and provides recommendations for improvement.
File Placement: Ensures that the Terraform files are correctly placed within the proper module directories.
Duplicate Data Sources: Identifies any duplicate data source declarations across your Terraform code.
Missing Descriptions: Flags resources, variables, or outputs missing descriptions in their blocks.
Resource Naming: Enforces a consistent naming convention for resources and data sources.
Unused Variables: Finds variables that are declared but not used in your Terraform files.
Declared Variables: Identifies variables that are referenced but not declared in the code.
Installation
To install the TerraformCodeReviewer extension:
Open Visual Studio Code.
Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.
Search for TerraformCodeReviewer and click Install.
Alternatively, you can install the extension via the command line: