com um clique
atmos-gitops
// CI/CD: GitHub Actions, Spacelift, Atlantis, `atmos describe affected` for change detection
// CI/CD: GitHub Actions, Spacelift, Atlantis, `atmos describe affected` for change detection
[HINT] Baixe o diretório completo da skill incluindo SKILL.md e todos os arquivos relacionados
| name | atmos-gitops |
| description | CI/CD: GitHub Actions, Spacelift, Atlantis, `atmos describe affected` for change detection |
| metadata | {"copyright":"Copyright Cloud Posse, LLC 2026","version":"1.0.0"} |
Atmos provides native CI/CD integration patterns for managing Terraform infrastructure through automated
pipelines. The three primary integration paths are GitHub Actions, Spacelift, and Atlantis. Each approach
leverages Atmos stack configurations and the atmos describe affected command to detect changes between
commits or branches, enabling efficient PR-based plan and merge-based apply workflows.
All integrations follow a common GitOps pattern:
atmos describe affectedatmos terraform plan for each affected component/stack pairatmos describe affectedThe atmos describe affected command is the foundation of all CI/CD integrations. It compares two Git
commits to produce a list of affected Atmos components and stacks.
The command performs these steps:
When component source directories have changed, all related stacks are marked affected and Atmos skips further configuration comparison for those stacks, streamlining the process.
# Compare current branch against the default branch (main)
atmos describe affected
# Compare against a specific branch
atmos describe affected --ref refs/heads/main
# Compare against a specific commit SHA
atmos describe affected --sha 6a9b2c1
# Use a pre-cloned repo for the target reference
atmos describe affected --repo-path /path/to/cloned/target
# Output as JSON for CI/CD consumption
atmos describe affected --format json
The command outputs a JSON array of affected items. Each item contains:
[
{
"component": "vpc",
"component_type": "terraform",
"stack": "plat-ue2-dev",
"stack_slug": "plat-ue2-dev-vpc",
"affected": "stack.vars"
},
{
"component": "eks/cluster",
"component_type": "terraform",
"stack": "plat-ue2-prod",
"stack_slug": "plat-ue2-prod-eks-cluster",
"affected": "component"
}
]
Fields:
component -- The Atmos component namecomponent_type -- Always terraform for Terraform componentsstack -- The Atmos stack namestack_slug -- A slug combining stack and component (used for matrix grouping)affected -- What changed: component (source files), stack.vars, stack.env, stack.settings, etc.The output can be filtered and grouped for GitHub Actions matrix strategies using jq expressions
configured in atmos.yaml:
# atmos.yaml
integrations:
github:
gitops:
matrix:
sort-by: .stack_slug
group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-")
The group-by expression creates groups for parallel execution, which helps work around the
GitHub Actions 256-job matrix limit.
Cloud Posse provides a set of GitHub Actions designed for Atmos-native GitOps workflows. These actions are open source (Apache 2.0 license), require no subscriptions, and use GitHub OIDC for authentication (no hardcoded credentials).
GitHub Actions that manage planfiles require:
id, GSI: pr-createdAt-index)integrations.github.gitops section# atmos.yaml
integrations:
github:
gitops:
terraform-version: 1.5.2
infracost-enabled: false
artifact-storage:
region: us-east-2
bucket: cptest-core-ue2-auto-gitops
table: cptest-core-ue2-auto-gitops-plan-storage
role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha
role:
plan: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
apply: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
matrix:
sort-by: .stack_slug
group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-")
atmos terraform plan, stores planfiles in S3, posts Job Summariesatmos terraform applyatmos describe affected and outputs a matrix for parallel jobsThe standard PR-based workflow:
affected-stacks action identifies changed components/stacks
b. Output feeds into a matrix strategy
c. atmos-terraform-plan runs for each affected component/stack pair
d. Plan summaries appear as GitHub Job Summariesatmos-terraform-apply retrieves stored planfiles from S3
b. Applies each affected component/stack pair
c. Apply summaries appear as Job SummariesDrift detection runs on a schedule (cron):
atmos terraform plan for each component/stack pairapply label to the Issueatmos terraform apply, and closes the IssueThe max-opened-issues input (default: 10) limits how many drift Issues are created per run.
GitHub Actions supports at most 256 matrix jobs per workflow. For large environments, use a two-level workflow pattern:
group-by jq expressionAtmos natively supports Spacelift through stack configuration settings and a Terraform module that reads YAML stack configs to provision Spacelift resources.
Configure Spacelift behavior in the settings.spacelift section of component configurations:
components:
terraform:
my-component:
settings:
spacelift:
workspace_enabled: true
administrative: false
autodeploy: true
before_init: []
component_root: components/terraform/my-component
description: "My component description"
stack_destructor_enabled: false
worker_pool_name: null
policies_enabled: []
administrative_trigger_policy_enabled: false
policies_by_id_enabled:
- my-custom-policy
terraform_workflow_tool: TERRAFORM # or OPEN_TOFU
Key settings:
workspace_enabled -- Whether this component/stack is managed in Spaceliftadministrative -- Whether this is an admin stack that manages other stacksautodeploy -- Automatically apply on merge without manual confirmationcomponent_root -- Path to the Terraform component directorypolicies_by_id_enabled -- List of Spacelift policy IDs to attachterraform_workflow_tool -- Use TERRAFORM or OPEN_TOFUDefine component dependencies using settings.depends_on:
components:
terraform:
my-component:
settings:
depends_on:
1:
component: "vpc"
2:
component: "eks/cluster"
tenant: "plat"
environment: "ue2"
stage: "prod"
Each dependency specifies a component (required) and optional context variables
(namespace, tenant, environment, stage) to reference components in other stacks.
To make OpenTofu the default for all Spacelift stacks:
settings:
spacelift:
terraform_workflow_tool: OPEN_TOFU
Or configure per-component to override the global setting.
Atmos supports Atlantis for Terraform Pull Request Automation through three commands:
atmos atlantis generate repo-config -- Generate atlantis.yaml repo-level configurationatmos terraform generate backends -- Generate backend configuration for all componentsatmos terraform generate varfiles -- Generate deep-merged varfiles for all stacksintegrations:
atlantis:
path: "atlantis.yaml"
config_templates:
config-1:
version: 3
automerge: true
delete_source_branch_on_merge: true
parallel_plan: true
parallel_apply: true
allowed_regexp_prefixes:
- dev/
- staging/
- prod/
project_templates:
project-1:
name: "{tenant}-{environment}-{stage}-{component}"
workspace: "{workspace}"
dir: "{component-path}"
terraform_version: v1.8
delete_source_branch_on_merge: true
autoplan:
enabled: true
when_modified:
- "**/*.tf"
- "varfiles/$PROJECT_NAME.tfvars"
apply_requirements:
- "approved"
workflow_templates:
workflow-1:
plan:
steps:
- run: terraform init -input=false
- run: terraform workspace select $WORKSPACE
- run: terraform plan -input=false -refresh -out $PLANFILE -var-file varfiles/$PROJECT_NAME.tfvars
apply:
steps:
- run: terraform apply $PLANFILE
atmos atlantis generate repo-config --config-template config-1 --project-template project-1
This generates an atlantis.yaml file with a project entry for each Atmos component in every stack,
using the specified config and project templates.
Atlantis settings can also be overridden in stack manifests using settings.atlantis, which deep-merges
with the integrations.atlantis section in atmos.yaml.
Atmos supports environment promotion through its stack inheritance model:
stacks/catalog/Example promotion workflow:
main auto-apply to devstagingprodatmos describe affected to minimize CI/CD runtime by only planning/applying changed stacksgroup-by setting to work around the 256-job GitHub Actions limitmax-opened-issues to keep drift manageableatmos validate stacks early in CI/CD pipelines to catch configuration errorsGitHub Actions versions must match the Atmos version:
The integrations.github.gitops configuration in atmos.yaml is supported in Atmos >= 1.63.0. Earlier
versions pass the settings directly as GitHub Action inputs.