Skip to content

Allow parallel deploys of same component across different root stacks and tfstate buckets #225

@nitrocode

Description

@nitrocode

Have a question? Please checkout our Slack Community or visit our Slack Archive.

Slack Community

Describe the Feature

Allow parallel deploys of same component across different root stacks

Terragrunt, for example, will copy the terraform into a separate temporary directory for each terragrunt run.

For example, if we ran these 3 commands today at the same time locally, we'd have different terraform runs trying to save state into the backend that was last initialized which can be devastating.

atmos terraform eks --stack tenant-use2-dev
atmos terraform eks --stack tenant-use2-staging
atmos terraform eks --stack tenant-use2-prod

If each run created its own separate terraform data directory then these files would not have conflicting backends.

https://developer.hashicorp.com/terraform/cli/config/environment-variables#tf_data_dir
https://support.hashicorp.com/hc/en-us/articles/360043550953-Selecting-a-workspace-when-running-Terraform-in-automation

e.g.

# atmos terraform eks --stack tenant-use2-dev
# TF_DATA_DIR=.terraform-tenant-use2-dev
# the `environment` file would contain the workspace `tenant-use2-dev`
components/terraform/eks/.terraform-tenant-use2-dev/environment
# atmos terraform eks --stack tenant-use2-staging
# TF_DATA_DIR=.terraform-tenant-use2-staging
# the `environment` file would contain the workspace `tenant-use2-staging`
components/terraform/eks/.terraform-tenant-use2-staging/environment
# etc

Expected Behavior

Separate terraform namespace per run like terragrunt

Use Case

See above

Describe Ideal Solution

Match terragrunt

The above description may not be the exact way terragrunt does it but it would be good to see how they do it in order to match it since they have implemented it a while back so it should be a relatively stable spec.

Alternatives Considered

Run commands linearly

or

use atmos workflows to run linearly

or

run in spacelift

Additional Context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions