Skip to main content

Automate Common Workflows

Atmos workflows are a way of combining multiple commands into executable units of work.

tip

Refer to Atmos Workflows for more information about configuring workflows

To define workflows, add the following configurations:

  • In atmos.yaml, add the workflows section and configure the base path to the workflows:
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"
  • Add workflow manifests in the stacks/workflows folder. In this Quick Start example, we will define Atmos workflows in the networking.yaml and validation.yaml workflow manifests:
   │   # Centralized stacks configuration
   ├── stacks
   │   └── workflows
   │       ├── networking.yaml
   │       └── validation.yaml
  • Add the following Atmos workflows to the stacks/workflows/networking.yaml file:
name: Networking & Logging
description: Atmos workflows for managing VPCs and VPC Flow Logs

workflows:

plan-all-vpc-flow-logs:
description: |
Run 'terraform plan' on all 'vpc-flow-logs-bucket' components in all stacks
steps:
- command: terraform plan vpc-flow-logs-bucket -s plat-ue2-dev
- command: terraform plan vpc-flow-logs-bucket -s plat-uw2-dev
- command: terraform plan vpc-flow-logs-bucket -s plat-ue2-staging
- command: terraform plan vpc-flow-logs-bucket -s plat-uw2-staging
- command: terraform plan vpc-flow-logs-bucket -s plat-ue2-prod
- command: terraform plan vpc-flow-logs-bucket -s plat-uw2-prod

plan-all-vpc:
description: |
Run 'terraform plan' on all 'vpc' components in all stacks
steps:
- command: terraform plan vpc -s plat-ue2-dev
- command: terraform plan vpc -s plat-uw2-dev
- command: terraform plan vpc -s plat-ue2-staging
- command: terraform plan vpc -s plat-uw2-staging
- command: terraform plan vpc -s plat-ue2-prod
- command: terraform plan vpc -s plat-uw2-prod

apply-all-components:
description: |
Run 'terraform apply' on all components in all stacks
steps:
- command: terraform apply vpc-flow-logs-bucket -s plat-ue2-dev -auto-approve
- command: terraform apply vpc -s plat-ue2-dev -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-uw2-dev -auto-approve
- command: terraform apply vpc -s plat-uw2-dev -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-ue2-staging -auto-approve
- command: terraform apply vpc -s plat-ue2-staging -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-uw2-staging -auto-approve
- command: terraform apply vpc -s plat-uw2-staging -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-ue2-prod -auto-approve
- command: terraform apply vpc -s plat-ue2-prod -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-uw2-prod -auto-approve
- command: terraform apply vpc -s plat-uw2-prod -auto-approve
  • Add the following Atmos workflows to the stacks/workflows/validation.yaml file:
name: Validation
description: Atmos workflows for VPCs and VPC Flow Logs validation

workflows:

validate-all-vpc-flow-logs:
description: "Validate all VPC Flow Logs bucket components in all stacks"
steps:
- command: validate component vpc-flow-logs-bucket -s plat-ue2-dev
- command: validate component vpc-flow-logs-bucket -s plat-uw2-dev
- command: validate component vpc-flow-logs-bucket -s plat-ue2-staging
- command: validate component vpc-flow-logs-bucket -s plat-uw2-staging
- command: validate component vpc-flow-logs-bucket -s plat-ue2-prod
- command: validate component vpc-flow-logs-bucket -s plat-uw2-prod

validate-all-vpc:
description: "Validate all VPC components in all stacks"
steps:
- command: validate component vpc -s plat-ue2-dev
- command: validate component vpc -s plat-uw2-dev
- command: validate component vpc -s plat-ue2-staging
- command: validate component vpc -s plat-uw2-staging
- command: validate component vpc -s plat-ue2-prod
- command: validate component vpc -s plat-uw2-prod
  • Run the following Atmos commands to execute the workflows:
# Execute the workflow `plan-all-vpc-flow-logs` from the workflow manifest `networking.yaml`
atmos workflow plan-all-vpc-flow-logs -f networking

# Execute the workflow `plan-all-vpc` from the workflow manifest `networking.yaml`
atmos workflow plan-all-vpc -f networking

# Execute the workflow `apply-all-components` from the workflow manifest `networking.yaml`
atmos workflow apply-all-components -f networking

# Execute the workflow `validate-all-vpc-flow-logs` from the workflow manifest `validation.yaml`
atmos workflow validate-all-vpc-flow-logs -f validation

# Execute the workflow `validate-all-vpc` from the workflow manifest `validation.yaml`
atmos workflow validate-all-vpc -f validation
tip

Refer to atmos workflow for more information on the atmos workflow CLI command

The atmos workflow CLI command supports the --dry-run flag. If passed, the command will just print information about the executed workflow steps without executing them. For example:

atmos workflow plan-all-vpc -f networking --dry-run

Executing the workflow 'plan-all-vpc' from 'stacks/workflows/networking.yaml'

Executing workflow step: terraform plan vpc -s plat-ue2-dev
Executing workflow step: terraform plan vpc -s plat-uw2-dev
Executing workflow step: terraform plan vpc -s plat-ue2-staging
Executing workflow step: terraform plan vpc -s plat-uw2-staging
Executing workflow step: terraform plan vpc -s plat-ue2-prod
Executing workflow step: terraform plan vpc -s plat-uw2-prod