atmos terraform generate planfile
Usage​
Execute the terraform generate planfile
command like this:
atmos terraform generate planfile <component> -s <stack> [options]
This command generates a Terraform planfile for a specified Atmos component in a stack.
Under the hood, Atmos executes terraform plan
to create a binary planfile, then uses terraform show
to convert it into a human-readable format (YAML or JSON). This enables easy integration with other tooling like checkov
.
Run atmos terraform generate planfile --help
to see all the available options
Examples​
atmos terraform generate planfile component1 -s plat-ue2-dev
atmos terraform generate planfile component1 -s plat-ue2-prod --format=json
atmos terraform generate planfile component1 -s plat-ue2-prod --format=yaml
atmos terraform generate planfile <component> -s <stack> --file=planfile.json
atmos terraform generate planfile <component> -s <stack> --format=yaml --file=planfiles/planfile.yaml
atmos terraform generate planfile <component> -s <stack> --file=/Users/me/Documents/atmos/infra/planfile.json
Arguments​
component
(required)Atmos terraform component.
Flags​
--stack
(alias-s
) (required)Atmos stack.
--format
(optional)Output format (
json
oryaml
,json
is default).atmos terraform generate planfile <component> -s <stack> --format=json
atmos terraform generate planfile <component> -s <stack> --format=yaml--file
(alias-f
) (optional)Planfile name. Supports absolute and relative paths.
If not provided, Atmos generates the planfile in the Terraform component directory with the name
<stack>-<component>.planfile.json
or<stack>-<component>.planfile.yaml
, depending on the format specified with--format
flag (json
is default).If an absolute path is provided, the file will be created in the specified directory:
atmos terraform generate planfile <component> -s <stack> --file=/Users/me/Documents/atmos/infra/planfile.json
If a relative path is specified, the file will be created in the Terraform component directory:
atmos terraform generate planfile <component> -s <stack> --file=planfile.json
atmos terraform generate planfile <component> -s <stack> --format=yaml --file=planfiles/planfile.yaml--process-templates
(optional)Enable/disable Go template processing in Atmos stack manifests when executing terraform commands.
If the flag is not passed, template processing is enabled by default.
atmos terraform generate planfile <component> -s <stack> --process-templates=false
--process-functions
(optional)Enable/disable YAML functions processing in Atmos stack manifests
when executing terraform commands.If the flag is not passed, YAML function processing is enabled by default.
atmos terraform generate planfile <component> -s <stack> --process-functions=false
--skip
(optional)Skip processing a specific Atmos YAML function in Atmos stacks manifests when executing terraform commands.
To specify more than one function, use multiple
--skip
flags, or separate the functions with a comma.atmos terraform generate planfile <component> -s <stack> --skip=eval --skip=include
atmos terraform generate planfile <component> -s <stack> --skip=terraform.output,include
Validate Terraform/OpenTofu planfiles using Checkov​
You can generate a planfile for a component in a stack and validate it using Checkov.
atmos terraform generate planfile <component> -s <stack>
checkov --file components/terraform/<component>/<stack>-<component>.planfile.json --framework terraform_plan
Refer to Evaluate Checkov Policies on Terraform Plan for more information.