atmos terraform validate
Use this command to validate the Terraform HCL configuration files (.tf files) for an Atmos component in a stack, checking for syntax and consistency errors. This validates Terraform code, not Atmos stack YAML configurations.
Usage
Execute the terraform validate command like this:
atmos terraform validate <component> -s <stack> [options]
This command validates the Terraform HCL configuration files in a component directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc.
Atmos provides standard setup for this command including automatic terraform init and workspace selection. The validation itself is performed by native Terraform.
Configuration
Configure validation behavior in your atmos.yaml:
components:
terraform:
# Always run init before validate
init_run_reconfigure: false
# Auto-generate backend file for validation
auto_generate_backend_file: true
Validation includes:
- Checking for syntax errors
- Verifying internal consistency
- Ensuring all required arguments are specified
- Checking that all variables are declared
- Validating output value expressions
- Ensuring resource configurations are complete
Examples
Basic Validation
Validate a component in a stack:
atmos terraform validate vpc -s dev
Validation with JSON Output
Get validation results in JSON format for parsing:
atmos terraform validate vpc -s dev -json