atmos terraform fmt
Use this command to format Terraform HCL configuration files for an Atmos component to canonical format and style.
Usage​
Execute the terraform fmt command like this:
atmos terraform fmt <component> -s <stack> [options]
This command rewrites Terraform configuration files to a canonical format and style. This ensures consistency across your codebase and makes the code easier to read and maintain.
This is a pure passthrough command. Atmos does not perform automatic initialization, workspace management, or variable generation for terraform fmt. The command is executed directly in the component directory.
Examples​
Format Files​
# Format all Terraform files in the component directory
atmos terraform fmt vpc -s dev
Check Formatting Only​
# Check if files are formatted without changing them
atmos terraform fmt vpc -s dev -check
Format with Diff​
# Show what would be changed
atmos terraform fmt vpc -s dev -diff
Recursive Format​
# Format all files recursively
atmos terraform fmt vpc -s dev -recursive
Arguments​
component(required)Atmos component name.
Flags​
--stack/-s(required)Atmos stack name where the component is defined.
--skip-init(optional)Skip running
terraform initbefore executing the command.atmos terraform fmt vpc -s dev --skip-init--dry-run(optional)Show what would be executed without actually running the command.
atmos terraform fmt vpc -s dev --dry-run
Native Terraform Flags​
This command supports native terraform fmt flags such as -check to verify formatting, -diff to show differences, -recursive to format subdirectories, -write=false to disable file updates.
Related Commands​
atmos terraform plan- Generate execution planatmos terraform apply- Apply changesatmos terraform init- Initialize working directory