github cloudposse/atmos v1.30.0

latest releases: v1.88.1, v1, v1.88.0...
19 months ago

what

why

  • Allow configuring Atlantis Integration in the settings.atlantis section in the YAML stack configs (instead, or in addition to, configuring it in integrations.atlantis in atmos.yaml)

    Configuring the Atlantis Integration in the settings.atlantis sections in the stack configs has the following advantages:

    • The settings section is a first class section in Atmos (similar to vars). It participates in deep-merging and in the inheritance chain. It can be defined and overridden at any level (organization/namespace, OU/tenant, region/environment, account/stage, base component, component). You can define the base settings at the org, tenant or account level, and then override some settings at the component level, making the whole configuration DRY

    • When executing the atmos atlantis generate repo-config command, you don't need to pass the --config-template and --project-template flags to specify which config and project templates to use. Instead, Atmos will get this information from the settings.atlantis section

    • When executing the atmos describe component <component> -s <stack> command, you will see the configured Atlantis Integration in the outputs. For example:

        atmos_component: test/test-component-override
        atmos_stack: tenant1-ue2-dev
        component: test/test-component
        settings:
          atlantis:
            config_template:
              allowed_regexp_prefixes:
              - dev/
              automerge: false
              delete_source_branch_on_merge: false
              parallel_apply: false
              parallel_plan: true
              version: 3
            config_template_name: config-1
            project_template:
              apply_requirements:
              - approved
              autoplan:
                enabled: true
                when_modified:
                - '**/*.tf'
                - varfiles/$PROJECT_NAME.tfvars.json
              delete_source_branch_on_merge: false
              dir: '{component-path}'
              name: '{tenant}-{environment}-{stage}-{component}'
              terraform_version: v1.3
              workflow: workflow-1
              workspace: '{workspace}'
            project_template_name: project-1
            workflow_templates:
              workflow-1:
                apply:
                  steps:
                  - run: terraform apply $PLANFILE
                plan:
                  steps:
                  - run: terraform init
                  - run: terraform workspace select $WORKSPACE || terraform workspace new $WORKSPACE
                  - run: terraform plan -out $PLANFILE -var-file varfiles/$PROJECT_NAME.tfvars.json
          spacelift:
            protect_from_deletion: true
            stack_destructor_enabled: false
            workspace_enabled: true
        vars:
          enabled: true
          environment: ue2
          namespace: cp
          region: us-east-2
          stage: dev
          tenant: tenant1
        workspace: test-component-override-workspace-override
    • If you configure the Atlantis Integration in the settings.atlantis sections in the stack configs, then the
      command atmos describe affected will be able to use it and output the affected Atlantis projects in the atlantis_project field. For example:

      [
         {
            "component": "infra/vpc",
            "component_type": "terraform",
            "component_path": "components/terraform/infra/vpc",
            "stack": "tenant1-ue2-dev",
            "atlantis_project": "tenant1-ue2-dev-infra-vpc",
            "affected": "component"
         },
         {
            "component": "infra/vpc",
            "component_type": "terraform",
            "component_path": "components/terraform/infra/vpc",
            "stack": "tenant1-ue2-prod",
            "atlantis_project": "tenant1-ue2-prod-infra-vpc",
            "affected": "component"
         }
      ]
  • Add --affected-only flag to atmos atlantis generate repo-config command

    If you want to generate the atlantis.yaml file before Atlantis can parse it, you can use the Dynamic Repo Config Generation feature of Atlantis. You can add a run command to pre_workflow_hooks. The repo config will be generated right before Atlantis can parse it.

    repos:
      - id: /.*/
        pre_workflow_hooks:
          - run: "./repo-config-generator.sh"
            description: "Generating configs"

    To help with dynamic repo config generation, the atmos atlantis generate repo-config command accepts the --affected-only flag. If set to true, Atmos will generate Atlantis projects only for the Atmos components changed between two Git commits.

    repos:
      - id: /.*/
        pre_workflow_hooks:
          - run: "atmos atlantis generate repo-config --affected-only=true"
            description: "Generating configs"

    If the --affected-only=true flag is passed, Atmos uses two different Git commits to produce a list of affected Atmos components and stacks and then generate the atlantis.yaml file for the affected Atlantis projects only.

  • Update atmos describe affected command to include the atlantis_project attribute in the output of the affected components and stacks. The attribute shows the affected Atlantis projects between two diff Git commits (Note that this works only when Atlantis integration is configured in the settings.atlantis sections in the YAML stack config (see the description above)

    [
       {
          "component": "infra/vpc",
          "component_type": "terraform",
          "component_path": "components/terraform/infra/vpc",
          "stack": "tenant1-ue2-dev",
          "atlantis_project": "tenant1-ue2-dev-infra-vpc",
          "affected": "component"
       },
       {
          "component": "infra/vpc",
          "component_type": "terraform",
          "component_path": "components/terraform/infra/vpc",
          "stack": "tenant1-ue2-prod",
          "atlantis_project": "tenant1-ue2-prod-infra-vpc",
          "affected": "component"
       }
    ]
  • Add --format and --file flags to atmos describe component command - useful to have when working with the command in GitHub actions and OPA validation

related

Don't miss a new atmos release

NewReleases is sending notifications on new releases.