Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workspace_key_prefix prefix to use an existing s3 tfstate bucket #430

Open
nitrocode opened this issue Sep 25, 2023 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@nitrocode
Copy link
Member

Describe the Feature

I'd like to use an existing s3 bucket for tfstate for an atmos poc without cluttering up the s3 bucket's root space.

Preferably, i'd like to add a workspace_key_prefix of atmos/ before the component name

Expected Behavior

Everything is in root space

$ aws s3 ls s3://some-tfstate-bucket/
                           PRE ecr/           # from atmos
                           PRE hello-world/   # from atmos
                           PRE existing/
                           PRE # ...

Use Case

See above

Describe Ideal Solution

Add prefix for workspace prefix such as workspace_key_prefix_prefix or workspace_directory

Alternatives Considered

Create a new bucket

Additional Context

No response

@aknysh
Copy link
Member

aknysh commented Sep 27, 2023

workspace_key_prefix can be specified per component, e.g.

  components:
    terraform:
      vpc:
        backend:
          s3:
            workspace_key_prefix: "my-vpc"

If not specified, then Atmos generates it automatically using the Atmos component name.
In the above case, if you don't use workspace_key_prefix: "my-vpc", then it will be set to vpc (Atmos component name).

And since the backend section participates in all the inheritance and deep-merging, you can specify workspace_key_prefix in any of the base abstract components, in a mixin, or any other config that would be applied to the component in question

@nitrocode is this what you are asking?

@nitrocode
Copy link
Member Author

Hi @aknysh , it's similar. I want the workspace_key_prefix to be prefixed with another hard coded value which at the moment atmos does not support.

For example, a workspace_key_prefix equal to my <component> will give me this in my S3 bucket.

s3://tfstate-bucket/<component>

What I want is to prefix the workspace_key_prefix with a root level directory

s3://tfstate-bucket/<root-level-directory>/<component>

e.g.

  components:
    terraform:
      vpc:
        backend:
          s3:
            workspace_key_prefix: "vpc"
            workspace_key_prefix_prefix: "atmos/"

which should result in this

s3://tfstate-bucket/atmos/vpc

I don't want to do it on a per-component level (like in the example above) but on a global level where I define all my bucket information.

@osterman osterman added the enhancement New feature or request label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants