Configure CLI
In the previous step, we've decided on the following:
- Use a monorepo to configure and provision two Terraform components into three AWS accounts and two AWS regions
- The filesystem layout for the infrastructure monorepo
- To be able to use Component Remote State, we put the
atmos.yaml
CLI config file into/usr/local/etc/atmos/atmos.yaml
folder and set the ENV varATMOS_BASE_PATH
to point to the absolute path of the root of the repo
Next step is to configure atmos.yaml
.
atmos.yaml
configuration file is used to control the behavior of the atmos
CLI. The file supports many features that are configured in different
sections of the atmos.yaml
file. For the description of all the sections, refer to CLI Configuration.
For the purpose of this Quick Start, below is the minimum configuration required for Atmos to work with Terraform and to
configure Atmos components and Atmos stacks. Copy the YAML config below into your atmos.yaml
file.
# CLI config is loaded from the following locations (from lowest to highest priority):
# system dir ('/usr/local/etc/atmos' on Linux, '%LOCALAPPDATA%/atmos' on Windows)
# home dir (~/.atmos)
# current directory
# ENV vars
# Command-line arguments
#
# It supports POSIX-style Globs for file names/paths (double-star '**' is supported)
# https://en.wikipedia.org/wiki/Glob_(programming)
# Base path for components, stacks and workflows configurations.
# Can also be set using 'ATMOS_BASE_PATH' ENV var, or '--base-path' command-line argument.
# Supports both absolute and relative paths.
# If not provided or is an empty string, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path'
# and 'workflows.base_path' are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path'
# and 'workflows.base_path' are considered paths relative to 'base_path'.
base_path: ""
components:
terraform:
# Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_BASE_PATH' ENV var, or '--terraform-dir' command-line argument
# Supports both absolute and relative paths
base_path: "components/terraform"
# Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE' ENV var
apply_auto_approve: false
# Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT' ENV var, or '--deploy-run-init' command-line argument
deploy_run_init: true
# Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE' ENV var, or '--init-run-reconfigure' command-line argument
init_run_reconfigure: true
# Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE' ENV var, or '--auto-generate-backend-file' command-line argument
auto_generate_backend_file: false
stacks:
# Can also be set using 'ATMOS_STACKS_BASE_PATH' ENV var, or '--config-dir' and '--stacks-dir' command-line arguments
# Supports both absolute and relative paths
base_path: "stacks"
# Can also be set using 'ATMOS_STACKS_INCLUDED_PATHS' ENV var (comma-separated values string)
included_paths:
- "orgs/**/*"
# Can also be set using 'ATMOS_STACKS_EXCLUDED_PATHS' ENV var (comma-separated values string)
excluded_paths:
- "**/_defaults.yaml"
# Can also be set using 'ATMOS_STACKS_NAME_PATTERN' ENV var
name_pattern: "{tenant}-{environment}-{stage}"
workflows:
# Can also be set using 'ATMOS_WORKFLOWS_BASE_PATH' ENV var, or '--workflows-dir' command-line arguments
# Supports both absolute and relative paths
base_path: "stacks/workflows"
logs:
file: "/dev/stdout"
# Supported log levels: Trace, Debug, Info, Warning, Off
level: Info
# Custom CLI commands
commands: []
# Integrations
integrations: {}
# Validation schemas (for validating atmos stacks and components)
schemas: {}
The atmos.yaml
configuration file defines the following sections.
NOTE: below is the description of the sections relevant to this Quick Start guide. For the description of all the sections, refer to CLI Configuration.
base_path
- the base path for components, stacks and workflows configurations. We set it to an empty string because we've decided to use the ENV varATMOS_BASE_PATH
to point to the absolute path of the root of the repocomponents.terraform.base_path
- the base path to the Terraform components (Terraform root modules). As described in Configure Repository, we've decided to put the Terraform components into thecomponents/terraform
directory, and this setting tells Atmos where to find them. Atmos will join the base path (set in theATMOS_BASE_PATH
ENN var) withcomponents.terraform.base_path
to calculate the final path to the Terraform componentscomponents.terraform.apply_auto_approve
- if set totrue
, Atmos automatically adds the-auto-approve
option to instruct Terraform to apply the plan without asking for confirmation when executingterraform apply
commandcomponents.terraform.deploy_run_init
- if set totrue
, Atmos runsterraform init
before executingatmos terraform deploy
commandcomponents.terraform.init_run_reconfigure
- if set totrue
, Atmos automatically adds the-reconfigure
option to update the backend configuration when executingterraform init
commandcomponents.terraform.auto_generate_backend_file
- if set totrue
, Atmos automatically generates the Terraform backend file from the component configuration when executingterraform plan
andterraform apply
commandsstacks.base_path
- the base path to the Atmos stacks. As described in Configure Repository, we've decided to put the stack configurations into thestacks
directory, and this setting tells Atmos where to find them. Atmos will join the base path (set in theATMOS_BASE_PATH
ENN var) withstacks.base_path
to calculate the final path to the stacksstacks.included_paths
- list of file paths to the top-level stacks in thestacks
directory to include in search when Atmos searches for the stack where the component is defined when executingatmos
commandsstacks.excluded_paths
- list of file paths to the top-level stacks in thestacks
directory to exclude from search when Atmos searches for the stack where the component is defined when executingatmos
commandsstacks.name_pattern
- Atmos stack name pattern. When executingatmos
commands, Atmos does not use the configuration file names and their filesystem locations to search for the stack where the component is defined. Instead, Atmos uses the context variables (namespace
,tenant
,environment
,stage
) to search for the stack. The stack config file names can be anything, and they can be in any folder in any sub-folder in thestacks
directory. For example, when executing theatmos terraform apply infra/vpc -s tenant1-ue2-dev
command, the stacktenant1-ue2-dev
is specified by the-s
flag. By looking atname_pattern: "{tenant}-{environment}-{stage}"
and processing the tokens, Atmos knows that the first part of the stack name istenant
, the second part isenvironment
, and the third part isstage
. Then Atmos searches for the stack configuration file (in thestacks
directory) wheretenant: tenant1
,environment: ue2
andstage: dev
are defined (inline or via imports)workflows.base_path
- the base path to Atmos workflow fileslogs.verbose
- set totrue
to increase log verbosity. When set totrue
, Atmos prints to the console all the steps it takes to find and process theatmos.yaml
CLI config file, and all the steps it takes to find the stack and find and process the component in the stack