atmos terraform
Use these subcommands to interact with terraform.
Usage
Executes terraform commands.
atmos terraform <command> <component> -s <stack> [options]
atmos terraform <command> <component> --stack <stack> [options]
atmos supports all terraform commands and options described in Terraform CLI reference.
In addition, the component argument and stack flag are required to generate variables and backend config for the component in the stack.
Additions and differences from native terraform:
before executing other
terraformcommands,atmosrunsterraform inityou can skip over atmos calling
terraform initif you know your project is already in a good working state by using the--skip-initflag like soatmos terraform <command> <component> -s <stack> --skip-initatmos terraform deploycommand executesterraform planand thenterraform applyatmos terraform deploycommand supports--deploy-run-init=true|falseflag to enable/disable runningterraform initbefore executing the commandatmos terraform deploycommand sets-auto-approveflag before runningterraform applyatmos terraform applyandatmos terraform deploycommands support--from-planflag. If the flag is specified, the commands will use the previously generatedplanfileinstead of generating a newvarfileatmos terraform cleancommand deletes the.terraformfolder,.terraform.lock.hcllock file, and the previously generatedplanfileandvarfilefor the specified component and stackatmos terraform workspacecommand first runsterraform init -reconfigure, thenterraform workspace select, and if the workspace was not created before, it then runsterraform workspace newatmos terraform importcommand searches forregionin the variables for the specified component and stack, and if it finds it, setsAWS_REGION=<region>ENV var before executing the commandatmos terraform generate backendcommand generates a backend config file for anatmoscomponent in a stackatmos terraform generate backendscommand generates backend config files for allatmoscomponents in all stacksatmos terraform generate varfilecommand generates a varfile for anatmoscomponent in a stackatmos terraform generate varfilescommand generates varfiles for allatmoscomponents in all stacksatmos terraform shellcommand configures an environment for anatmoscomponent in a stack and starts a new shell allowing executing all native terraform commands inside the shell
Run atmos terraform --help to see all the available options
Examples
atmos terraform plan test/test-component-override-3 -s tenant1-ue2-dev
atmos terraform apply test/test-component-override-3 -s tenant1-ue2-dev
atmos terraform destroy test/test-component-override-3 -s tenant1-ue2-dev
atmos terraform init test/test-component-override-3 -s tenant1-ue2-dev
atmos terraform workspace test/test-component-override-3 -s tenant1-ue2-dev
atmos terraform clean test/test-component-override-3 -s tenant1-ue2-dev
Arguments
| Argument | Description | Required |
|---|---|---|
component | atmos terraform component | yes |
Flags
| Flag | Description | Alias | Required |
|---|---|---|---|
--stack | atmos stack | -s | yes |
--dry-run | Dry-run | no |
All native terraform flags are supported
Subcommands
📄️ clean
Use this command to delete the .terraform folder, the folder that TFDATADIR ENV var points to, .terraform.lock.hcl file, varfile and planfile for a
📄️ generate backend
Use this command to generate a backend config file for an `atmos` terraform component in a stack.
📄️ generate backends
Use this command to generate the Terraform "backend config" files for all `atmos` Terraform Components in all Stacks.
📄️ generate varfile
Use this command to generate a varfile (.tfvar ) for a Terraform Component in a Stack.
📄️ generate varfiles
Use this command to generate the Terraform varfiles (`.tfvar`) for all `atmos` Terraform Components in all Stacks.
📄️ shell
This command starts a new `SHELL` configured with the environment for an `atmos` Component in a Stack so allow executing all native terraform commands inside of the shell without using any atmos-specific arguments and flags.
📄️ workspace
This command calculates the `terraform` workspace for an `atmos` component (from the context variables and stack config), then runs `terraform init -reconfigure`, then selects the workspace by executing the `terraform workspace select` command.