github cloudposse/atmos v1.4.4

latest releases: v1.100.0, v1, v1.99.0...
2 years ago

what

  • Add atmos describe stacks command
  • Allow writing the result to a file by using --file command-line flag
  • Allow formatting the result as YAML or JSON by using --format command-line flag
  • Allow filtering of the result by using the command-line flags: stack, component-types, components, sections
  • Available component sections: backend, backend_type, deps, env, inheritance, metadata, remote_state_backend, remote_state_backend_type, settings, vars

why

  • Command to show stack configs and all the components in the stacks
  • Slice and dice the stack config to show different information about stacks and components

usage

atmos describe stacks
atmos describe stacks --component-types=helmfile
atmos describe stacks --component-types=terraform,helmfile
atmos describe stacks --components=infra/vpc
atmos describe stacks --components=echo-server
atmos describe stacks --components=echo-server,infra/vpc
atmos describe stacks --components=echo-server,infra/vpc --sections=vars
atmos describe stacks --components=echo-server,infra/vpc --sections=vars,settings
atmos describe stacks --components=test/test-component-override-3 --sections=inheritance
atmos describe stacks --components=test/test-component-override-3 --sections=component
atmos describe stacks --components=test/test-component-override-3 --sections=deps
atmos describe stacks --components=test/test-component-override-3 --sections=vars,settings --file=stacks.yaml
atmos describe stacks --components=test/test-component-override-3 --sections=vars,settings --format=json --file=stacks.json
atmos describe stacks --components=test/test-component-override-3 --sections=deps,vars -s=tenant2/ue2/staging

examples

Click to expand

Show all stacks with all the components with all the component sections (Warning: this will dump ALL YAML config for all components for all stacks to the console)

atmos describe stacks

......

tenant2/ue2/staging:
  components:
    terraform:
      test/test-component-override-3:
        backend:
          acl: bucket-owner-full-control
          bucket: eg-ue2-root-tfstate
          dynamodb_table: eg-ue2-root-tfstate-lock
          encrypt: true
          key: terraform.tfstate
          region: us-east-2
          role_arn: null
          workspace_key_prefix: test-test-component
        backend_type: s3
        command: terraform
        component: test/test-component
        deps:
        - catalog/terraform/services/service-1
        - catalog/terraform/services/service-2
        - catalog/terraform/test-component
        - catalog/terraform/test-component-override-3
        - globals/globals
        - globals/tenant2-globals
        - globals/ue2-globals
        - tenant2/ue2/staging
        env:
          TEST_ENV_VAR1: val1-override-3
          TEST_ENV_VAR2: val2-override-3
          TEST_ENV_VAR3: val3-override-3
          TEST_ENV_VAR4: val4-override-3
        inheritance:
        - mixin/test-2
        - mixin/test-1
        - test/test-component-override-2
        - test/test-component-override
        - test/test-component
        metadata:
          component: test/test-component
          inherits:
          - test/test-component-override
          - test/test-component-override-2
          - mixin/test-1
          - mixin/test-2
          terraform_workspace: test-component-override-3-workspace
          type: real
        remote_state_backend:
          acl: bucket-owner-full-control
          bucket: eg-ue2-root-tfstate
          dynamodb_table: eg-ue2-root-tfstate-lock
          encrypt: true
          key: terraform.tfstate
          region: us-east-2
          role_arn: arn:aws:iam::123456789012:role/eg-gbl-root-terraform
          workspace_key_prefix: test-test-component
        remote_state_backend_type: s3
        settings:
          spacelift:
            stack_name_pattern: '{tenant}-{environment}-{stage}-new-component'
            workspace_enabled: false
        vars:
          enabled: true
          environment: ue2
          namespace: eg
          region: us-east-2
          service_1_list:
          - 5
          - 6
          - 7
          service_1_map:
            a: 1
            b: 6
            c: 7
            d: 8
          service_1_name: mixin-2
          service_2_list:
          - 4
          - 5
          - 6
          service_2_map:
            a: 4
            b: 5
            c: 6
          service_2_name: service-2-override-2
          stage: staging
          tenant: tenant2

....

Show only stacks with terraform components

atmos describe stacks --component-types=terraform

Show only stacks with helmfile components

atmos describe stacks --component-types=helmfile

Show only a specific stack with all the components with all the component sections

atmos describe stacks -s=tenant2/ue2/staging

Show only the stacks where a specific component is configured (with all component sections)

atmos describe stacks --components=infra/vpc

Show only the stacks where the specific components are configured (with all component sections)

atmos describe stacks --components=echo-server,infra/vpc

Show only the specific sections for the components in all stacks

atmos describe stacks --components=echo-server,infra/vpc --sections=vars,settings
atmos describe stacks --components=test/test-component-override-3 --sections=inheritance
atmos describe stacks --components=test/test-component-override-3 --sections=component
atmos describe stacks --components=test/test-component-override-3 --sections=deps

Write the result to a file (in YAML format)

atmos describe stacks --sections=vars,settings --file=stacks.yaml

Write the result to a file (in JSON format)

atmos describe stacks --sections=vars,settings --format=json --file=stacks.json

Show all configured stacks (by specifying a non existing component in the filter)

atmos describe stacks --components=none

tenant1/ue2/dev: {}
tenant1/ue2/prod: {}
tenant1/ue2/staging: {}
tenant2/ue2/dev: {}
tenant2/ue2/prod: {}
tenant2/ue2/staging: {}

Show all components in all stacks with just the component names (by specifying a non existing section in the filter)

atmos describe stacks --sections=none

tenant1/ue2/dev:
  components:
    helmfile:
      echo-server: {}
      infra/infra-server: {}
      infra/infra-server-override: {}
    terraform:
      infra/vpc: {}
      mixin/test-1: {}
      mixin/test-2: {}
      test/test-component: {}
      test/test-component-override: {}
      test/test-component-override-2: {}
      test/test-component-override-3: {}
      top-level-component1: {}
tenant1/ue2/prod:
  components:
    helmfile:
      echo-server: {}
      infra/infra-server: {}
      infra/infra-server-override: {}
    terraform:
      infra/vpc: {}
      mixin/test-1: {}
      mixin/test-2: {}
      test/test-component: {}
      test/test-component-override: {}
      test/test-component-override-2: {}
      test/test-component-override-3: {}
      top-level-component1: {}
tenant1/ue2/staging:
  components:
    helmfile:
      echo-server: {}
      infra/infra-server: {}
      infra/infra-server-override: {}
    terraform:
      infra/vpc: {}
      mixin/test-1: {}
      mixin/test-2: {}
      test/test-component: {}
      test/test-component-override: {}
      test/test-component-override-2: {}
      test/test-component-override-3: {}
      top-level-component1: {}
tenant2/ue2/dev:
  components:
    helmfile:
      echo-server: {}
      infra/infra-server: {}
      infra/infra-server-override: {}
    terraform:
      infra/vpc: {}
      mixin/test-1: {}
      mixin/test-2: {}
      test/test-component: {}
      test/test-component-override: {}
      test/test-component-override-2: {}
      test/test-component-override-3: {}
      top-level-component1: {}
tenant2/ue2/prod:
  components:
    helmfile:
      echo-server: {}
      infra/infra-server: {}
      infra/infra-server-override: {}
    terraform:
      infra/vpc: {}
      mixin/test-1: {}
      mixin/test-2: {}
      test/test-component: {}
      test/test-component-override: {}
      test/test-component-override-2: {}
      test/test-component-override-3: {}
      top-level-component1: {}
tenant2/ue2/staging:
  components:
    helmfile:
      echo-server: {}
      infra/infra-server: {}
      infra/infra-server-override: {}
    terraform:
      infra/vpc: {}
      mixin/test-1: {}
      mixin/test-2: {}
      test/test-component: {}
      test/test-component-override: {}
      test/test-component-override-2: {}
      test/test-component-override-3: {}
      top-level-component1: {}

Show only a specific component in all stacks with just the component name (by specifying a non existing section in the filter) - this shows in which stacks the specified component exists

atmos describe stacks --components=infra/vpc --sections=none

tenant1/ue2/dev:
  components:
    terraform:
      infra/vpc: {}
tenant1/ue2/prod:
  components:
    terraform:
      infra/vpc: {}
tenant1/ue2/staging:
  components:
    terraform:
      infra/vpc: {}
tenant2/ue2/dev:
  components:
    terraform:
      infra/vpc: {}
tenant2/ue2/prod:
  components:
    terraform:
      infra/vpc: {}
tenant2/ue2/staging:
  components:
    terraform:
      infra/vpc: {}

Don't miss a new atmos release

NewReleases is sending notifications on new releases.