Skip to content

Releases: cloudposse/atmos

v1.8.1

22 Sep 22:08
9f3993c
Compare
Choose a tag to compare

what

  • Use namespace context variable in the code that is used to return remote-state for a component in a stack

why

  • For stacks config using multiple Orgs, we use namespace in stack names, and need to be able to find the remote state of the components provisioned in these stack

v1.8.0

14 Sep 16:57
6319acb
Compare
Choose a tag to compare

what

  • Remove the default hardcoded CLI config
  • Update TF workspace calculation for Spacelift stacks

why

  • Make atmos.yaml CLI config always required. Remove the default hardcoded CLI config b/c it had some default values which are not applicable for all use cases. Instead, throw error if atmos.yaml is not found
export ATMOS_LOGS_VERBOSE=true
atmos describe component test/test-component-override -s tenant1-ue2-dev

Found ENV var ATMOS_LOGS_VERBOSE=true

Searching, processing and merging atmos CLI configurations (atmos.yaml) in the following order:
system dir, home dir, current dir, ENV vars, command-line arguments

No config file atmos.yaml found in path '/usr/local/etc/atmos/atmos.yaml'.
No config file atmos.yaml found in path '/Users/xxxxx/.atmos/atmos.yaml'.
No config file atmos.yaml found in path '/Go/src/github.com/cloudposse/atmos/atmos.yaml'.

'atmos.yaml' CLI config files not found in any of the searched paths: system dir, home dir, current dir, ENV vars.
You can download a sample config and adapt it to your requirements from https://raw.githubusercontent.com/cloudposse/atmos/master/examples/complete/atmos.yaml
  • Add a separate function to process component metadata section to make the code more DRY, and use it to calculate the TF workspaces for atmos commands and for Spacelift stacks

  • Fix TF workspace calculation for Spacelift stacks for rare cases when the atmos component name in YAML config is the same as its Terraform component name (specified in component or metadata.component attributes). This fixes TF workspaces for Spacelift stacks for atmos components like the following

components:
  terraform:
    glue/iam:
      metadata:
        component: glue/iam  # Terraform component (this is not necessary to specify since the TF component, if not specified, will be assumed to be the same as the atmos YAML component)

v1.7.1

13 Sep 17:34
e36d548
Compare
Choose a tag to compare

what

  • Fixes an issue where ATMOS_CLI_CONFIG_PATH points to a non directory and results in a panic.

why

  • This provides proper messaging and gracefully fails.
  • The error in question here that was getting skipped over by os.IsNotExist(err) was the following:
    • stat /usr/local/etc/atmos/atmos.yaml/atmos.yaml: not a directory

v1.7.0

11 Sep 17:32
c7e5f64
Compare
Choose a tag to compare

what

  • Add atmos terraform generate backends command

why

  • Generate terraform backend configs for all terraform components
  • Supported formats HCL and JSON
  • A GitHub Action that generates all .tfvar files and backend.tf files so that projects can be used with conventional terraform GitOps tools like atlantis, Terraform Cloud, et al.

test

# hcl is default, no need to specify it
atmos terraform generate backends --format=hcl

Writing backend config for the terraform component 'test/test-component' to file 'examples/complete/components/terraform/test/test-component/backend.tf'
Writing backend config for the terraform component 'infra/vpc' to file 'examples/complete/components/terraform/infra/vpc/backend.tf'
Writing backend config for the terraform component 'top-level-component1' to file 'examples/complete/components/terraform/top-level-component1/backend.tf'
atmos terraform generate backends --format=json

Writing backend config for the terraform component 'test/test-component' to file 'examples/complete/components/terraform/test/test-component/backend.tf.json'
Writing backend config for the terraform component 'infra/vpc' to file 'examples/complete/components/terraform/infra/vpc/backend.tf.json'
Writing backend config for the terraform component 'top-level-component1' to file 'examples/complete/components/terraform/top-level-component1/backend.tf.json'

image

v1.6.0

10 Sep 20:46
9556860
Compare
Choose a tag to compare

what

  • Update atmos atlantis generate repo-config command
  • Support native HCL output format in atmos terraform generate varfiles command

why

  • Do not iterate over Go maps in atmos atlantis generate repo-config command. Go iterates over maps in a non-deterministic order resulting in constant drift in the final atlantis.yaml file. Instead, get the map keys, sort them, and iterate over the sorted keys
  • Support native HCL output format in atmos terraform generate varfiles command - when ejecting from atmos, the varfiles should be in the more native terraform format of HCL rather than JSON (although JSON is definitely a supported format and useful in some situations). The --format command-line argument now support --format=hcl

test

atmos terraform generate varfiles --format=hcl --file-template=./varfiles/{tenant}-{environment}-{stage}-{component}.tfvars

image

v1.5.1

10 Sep 01:25
317ed16
Compare
Choose a tag to compare

what

  • Adds a --skip-init flag which allows skipping terraform init

why

  • This can help speed up workflows in the case that the user knows their last command successfully ran terraform init and they do not need to run init again.

v1.5.0

07 Sep 15:49
9189ae8
Compare
Choose a tag to compare

what

  • Add support for custom integrations in atmos.yaml
  • Add Atlantis support (Atlantis is an integration)
  • Add atmos terraform generate varfiles and atmos atlantis generate repo-config CLI commands

why

  • Support Atlantis
  • Generate the varfiles for all components in all stacks (this is used in Atlantis repo config, and will be used to detect drifts in variables to simplify triggering Spacelift stacks)
  • Automatically generate Atlantis repo config file atlantis.yaml. Using the config, project and workflow templates, atmos generates atlantis projects which corresponds to an atmos components in all stacks

Both atmos terraform generate varfiles and atmos atlantis generate repo-config commands supports stacks and components parameters to generate Atlantis project configs for only specific stacks and/or components:

atmos terraform generate varfiles --components=test/test-component-override-3,infra/vpc --file-template=./varfiles/{tenant}/{environment}/{stage}/{component}.tfvars.json

atmos terraform generate varfiles --stacks=orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2 --file-template={component-path}/{tenant}/{environment}/{stage}/{component}.tfvars.json

atmos terraform generate varfiles --stacks=tenant1-ue2-staging --file-template={component-path}/{tenant}/{environment}/{stage}/{component}.tfvars.json

atmos terraform generate varfiles --stacks=tenant1-ue2-staging --components=infra/vpc --file-template={component-path}/{tenant}/{environment}/{stage}/{component}.tfvars.json
atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1 --components=test/test-component-override-3,infra/vpc

atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1 --stacks=orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2

atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1 --stacks=tenant1-ue2-staging,tenant1-ue2-prod

atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1 --stacks=tenant1-ue2-staging --components=infra/vpc

For each Atlantis project in atlantis.yaml, atmos automatically generates the correct values for these settings:

    workspace: test-component-override-3-workspace
    workflow: workflow-1
    dir: examples/complete/components/terraform/test/test-component

references

notes

atmos supports generating Repo Level atlantis.yaml Config for atmos components
and stacks.

The following atmos commands will first generate the varfiles for all components in all stacks,
then generate the atlantis.yaml repo config file:

atmos terraform generate varfiles --file-template=varfiles/{tenant}-{environment}-{stage}-{component}.tfvars.json
atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1

NOTE: All paths, --file-template in the atmos terraform generate varfiles command, and in the atlantis config in atmos.yaml, should be relative to the root of the repo.

Supported context tokens: {namespace}, {tenant}, {environment}, {region}, {stage}, {component}, {component-path}.

You can run these commands manually and commit the generated varfiles and atlantis.yaml repo config.

If you want to generate atlantis.yaml on the server dynamically,
you can add the following run commands to pre_workflow_hooks.
The atlantis.yaml repo config file will be generated right before Atlantis parses it.

repos:
  - id: /.*/
    pre_workflow_hooks:
      - run: |
          atmos terraform generate varfiles --file-template=varfiles/{tenant}-{environment}-{stage}-{component}.tfvars.json
          atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1

Note that the -file-template parameter in the atmos terraform generate varfiles command must match the following two settings in atmos.yaml:

  • when_modified must use the same template with the context tokens - this will allow Atlantis to check if any of the generated variables were
    modified
  • workflow extra_args must use the same template with the context tokens - this will allow Atlantis to run Terraform commands with the
    correct -var-file parameters
# atmos.yaml CLI config

# Integrations
integrations:

  # Atlantis integration
  # https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html
  atlantis:
    # Path and name of the Atlantis config file `atlantis.yaml`
    # Supports absolute and relative paths
    # All the intermediate folders will be created automatically (e.g. `path: /config/atlantis/atlantis.yaml`)
    # Can be overridden on the command line by using `--output-path` command-line argument in `atmos atlantis generate repo-config` command
    # If not specified (set to an empty string/omitted here, and set to an empty string on the command line), the content of the file will be dumped to `stdout`
    # On Linux/macOS, you can also use `--output-path=/dev/stdout` to dump the content to `stdout` without setting it to an empty string in `atlantis.path`
    path: "atlantis.yaml"

    # Config templates
    # Select a template by using the `--config-template <config_template>` command-line argument in `atmos atlantis generate repo-config` command
    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
    # Select a template by using the `--project-template <project_template>` command-line argument in `atmos atlantis generate repo-config` command
    project_templates:
      project-1:
        # generate a project entry for each component in every stack
        name: "{tenant}-{environment}-{stage}-{component}"
        workspace: "{workspace}"
        dir: "{component-path}"
        terraform_version: v1.2
        delete_source_branch_on_merge: true
        autoplan:
          enabled: true
          when_modified:
            - "**/*.tf"
            - "varfiles/$PROJECT_NAME.tfvars.json"
          apply_requirements:
            - "approved"

    # Workflow templates
    # https://www.runatlantis.io/docs/custom-workflows.html#custom-init-plan-apply-commands
    # https://www.runatlantis.io/docs/custom-workflows.html#custom-run-command
    # Select a template by using the `--workflow-template <workflow_template>` command-line argument in `atmos atlantis generate repo-config` command
    workflow_templates:
      workflow-1:
        plan:
          steps:
            - run: terraform init -input=false
            # When using workspaces, you need to select the workspace using the $WORKSPACE environment variable
            - run: terraform workspace select $WORKSPACE
            # You must output the plan using `-out $PLANFILE` because Atlantis expects plans to be in a specific location
            - run: terraform plan -input=false -refresh -out $PLANFILE -var-file varfiles/$PROJECT_NAME.tfvars.json
        apply:
          steps:
            - run: terraform apply $PLANFILE

Using the config, project and workflow templates, atmos generates a separate atlantis project for each atmos component in every stack:

version: 3
automerge: true
delete_source_branch_on_merge: true
parallel_plan: true
parallel_apply: true
allowed_regexp_prefixes:
  - dev/
  - staging/
  - prod/
projects:
  - name: tenant1-ue2-staging-test-test-component-override-3
    workspace: test-component-override-3-workspace
    workflow: workflow-1
    dir: examples/complete/components/terraform/test/test-component
    terraform_version: v1.2
    delete_source_branch_on_merge: true
    autoplan:
      enabled: true
      when_modified:
        - '**/*.tf'
        - varfiles/$PROJECT_NAME.tfvars.json
      apply_requirements:
        - approved
  - name: tenant1-ue2-staging-infra-vpc
    workspace: tenant1-ue2-staging
    workflow: workflow-1
    dir: examples/complete/components/terraform/infra/vpc
    terraform_version: v1.2
    delete_source_branch_on_merge: true
    autoplan:
      enabled: true
      when_modified:
        - '**/*.tf'
        - varfiles/$PROJECT_NAME.tfvars.json
      apply_requirements:
        - approved
workflows:
  workflow-1:
    apply:
      steps:
        - run: terraform apply $PLANFILE
    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.json

image


image



image


v1.4.28

30 Aug 15:11
9940032
Compare
Choose a tag to compare

what

  • Update atmos vendor pull

why

  • When pulling in mixins, override the destination file if it already exists
  • Prevent the error:
symlink components/terraform/mixins/context.tf components/terraform/infra/vpc-flow-logs-bucket/context.tf: file exists

v1.4.27

25 Aug 01:38
337c965
Compare
Choose a tag to compare

what

  • Update atmos vendor pull

why

  • Allow using absolute and relative file paths in component.yaml when vendoring mixins. This will allow having mixins in a local folder (and not in a private GitHub repo for which you'll have to use a GitHub token or other means to authenticate)
  # mixins override files from 'source' with the same 'filename' (e.g. 'context.tf' will override 'context.tf' from the 'source')
  # mixins are processed in the order they are declared in the list
  mixins:
    # Mixins 'uri' supports the following protocols: local files (absolute and relative paths), Git, Mercurial, HTTP, HTTPS, Amazon S3, Google GCP
    # This mixin `uri` is relative to the current `vpc-flow-logs-bucket` folder
    - uri: ../../mixins/context.tf
      filename: context.tf
    - uri: https://raw.githubusercontent.com/cloudposse/terraform-aws-components/{{.Version}}/modules/datadog-agent/introspection.mixin.tf
      version: 0.196.1
      filename: introspection.mixin.tf

v1.4.26

20 Aug 14:37
ffa7bd9
Compare
Choose a tag to compare

what

  • Update versions
  • Fix handling of partial stacks definitions
  • Improve error handling
  • Add an example of partial stacks definition

why

  • Update Go, Docker, Terraform to the latest version to keep up to date
  • When searching for the specified component in the specified stack (e.g. atmos describe component <component> -s <stack>), if any of the stack config files throws error (which also means that we can't find the component in that stack), print the error to the console and continue searching for the component in the other stack config files. This will allow having partial stack configs even if a partial stack config file does not provide all the required context variables (namespace, tenant, environment, stage) for all components in it (but specifies the context for some components, which we are interested in)
  • Print the above misconfiguration errors to the console in logs verbose mode (export ATMOS_LOGS_VERBOSE=true)
  • An example of partial stacks definition: examples/complete/stacks/orgs/cp/tenant1/dev/us-east-2-extras.yaml defines a new component new-vpc in the stack tenent1-ue2-dev; note that the same stack tenent1-ue2-dev is defined in examples/complete/stacks/orgs/cp/tenant1/dev/us-east-2.yaml but for different components