Terraform Configuration
Configure how Atmos executes Terraform and OpenTofu commands, including the base path for components, auto-approve behavior, backend file generation, and initialization options.
The term "Terraform" is used in this documentation to refer to generic concepts such as providers, modules, stacks, the HCL-based domain-specific language and its interpreter. Atmos works with both Terraform and OpenTofu.
Configurationβ
atmos.yaml
Configuration Referenceβ
commandSpecifies the executable to run for Terraform commands. Defaults to
terraform.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_COMMANDCommand-line flag:--terraform-commandExamples:
terraform- Use Terraform from PATHtofu- Use OpenTofu from PATH/usr/local/bin/terraform-1.8- Use specific version/usr/local/bin/tofu-1.7.1- Use specific OpenTofu version
base_pathDirectory containing Terraform component directories. Supports absolute and relative paths.
Environment variable:
ATMOS_COMPONENTS_TERRAFORM_BASE_PATHCommand-line flag:--terraform-dirapply_auto_approveWhen
true, Atmos adds-auto-approvetoterraform applycommands, skipping the confirmation prompt.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVEDefault:falsedeploy_run_initWhen
true, Atmos runsterraform initbefore executingatmos terraform deploy.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INITCommand-line flag:--deploy-run-initDefault:trueinit_run_reconfigureWhen
true, Atmos adds-reconfiguretoterraform initcommands, updating backend configuration.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURECommand-line flag:--init-run-reconfigureDefault:trueauto_generate_backend_fileWhen
true, Atmos generatesbackend.tf.jsonfrom stack configuration before running Terraform commands.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILECommand-line flag:--auto-generate-backend-fileDefault:trueauto_generate_filesWhen
true, Atmos generates files from thegeneratesection in stack configuration before running Terraform commands.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_FILESDefault:falseinit.pass_varsWhen
true, Atmos passes the generated varfile toterraform initusing--var-file. This is primarily useful with OpenTofu, which supports passing varfiles to init for dynamic backend configuration.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_INIT_PASS_VARSCommand-line flag:--init-pass-varsDefault:falseplan.skip_planfileWhen
true, Atmos skips creating a plan file duringterraform plan. The plan output is shown but not saved.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_PLAN_SKIP_PLANFILECommand-line flag:--skip-planfileDefault:falseplugin_cacheWhen
true, Atmos enables Terraform provider plugin caching by automatically settingTF_PLUGIN_CACHE_DIR. This improves performance by reusing downloaded providers across components, reducing init times and network bandwidth.When caching is enabled, Atmos also sets
TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE=trueas required by Terraform.If
TF_PLUGIN_CACHE_DIRis already set in your environment or via the globalenv:section inatmos.yaml, Atmos does not override itβyou manage your own cache.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_PLUGIN_CACHEDefault:trueplugin_cache_dirCustom directory path for the Terraform plugin cache. If empty (default), Atmos uses the XDG cache directory:
~/.cache/atmos/terraform/plugins.Environment variable:
ATMOS_COMPONENTS_TERRAFORM_PLUGIN_CACHE_DIRDefault:""(uses XDG cache directory)shell.promptCustom prompt to display when running
atmos terraform shell.
Using OpenTofuβ
To use OpenTofu instead of Terraform, set the command to tofu:
atmos.yaml
OpenTofu supports additional features like passing variables to init for dynamic backend configuration:
atmos.yaml
Generated Filesβ
When auto_generate_backend_file is enabled, Atmos generates a backend.tf.json file in each component directory. Add this to your .gitignore:
# Atmos generated files
backend.tf.json
Related Commandsβ
ποΈ atmos terraform
Execute Terraform/OpenTofu commands
ποΈ atmos terraform plan
Generate and show execution plan
ποΈ atmos terraform apply
Apply infrastructure changes
ποΈ atmos terraform deploy
Run init, plan, and apply in sequence
ποΈ atmos terraform shell
Open an interactive shell
ποΈ atmos terraform generate backends
Generate backend configuration files
ποΈ atmos terraform generate varfiles
Generate variable files
ποΈ atmos terraform generate files
Generate auxiliary configuration files