Repository navigation
Description
Describe the Feature
This is a similar idea to what Terragrunt does with their "Remote Terraform Configurations" feature: https://terragrunt.gruntwork.io/docs/features/keep-your-terraform-code-dry/#remote-terraform-configurations
The idea would be that you could provide a URL to a given root module and use that to create a component instance instead of having that component available locally in the atmos project repo.
The benefit here is that you don't need to vendor in the code for that root module. Vendoring is great when you're going to make changes to a configuration, BUT if you're not making any changes then it just creates large PRs that are hard to review and doesn't provide much value.
Another benefit: I have team members that strongly dislike creating root modules that are simply slim wrappers of a single child module because then we're in the game of maintaining a very slim wrapper. Kevin (@kevcube) can speak to that if there is interest to understand more there.
Expected Behavior
Today all non-custom root module usage is done through vendoring in Atmos, so no similar expected behavior AFAIK.
Use Case
Help avoid vendoring in code that you're not changing and therefore not polluting the atmos project with additional code that is unchanged.
Describe Ideal Solution
I'm envisioning this would work like the following with the $COMPONENT_NAME.metadata.url being the only change to the schema. Maybe we also need a version attribute as well, but TBD.
components:
terraform:
s3-bucket:
metadata:
url: https://github.com/cloudposse/terraform-aws-components/tree/1.431.0/modules/s3-bucket
vars:
...Running atmos against this configuration would result in atmos cloning that root module down to the local in a temporary cache and then using that cloned root module as the source to run terraform or tofu against.
Alternatives Considered
None.
Additional Context
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
Gowiem commentedon May 8, 2024
Erik Osterman (Cloud Posse) (@osterman) Andriy Knysh (@aknysh) RB (@nitrocode) -- Would be interested in your folks thoughts on this one!
osterman commentedon May 8, 2024
This has come up from a handful of people lately in the community. Clearly it's a popular feature for users migrating from a Terragrunt ecosystem.
This is supported today by combining 2 concepts.
How it's different from Terragrunt
atmos vendor pullbefore running commands. In other words, it's not Just in Time (JIT). We like not relying on temporary cache folders like Terragrunt.How we could improve it?
--vendorflag toatmos terraformcommands, so that it would know to vendor automatically. Then it would feel more "just in time"setting.vendor.pull = truewhich would look for matchingvendor.yamlcomponents and automatically pull them at run time. If we did this, we would also have to update theatmos describe affectedcommand.atmos describe affectedis not currently aware ofvendor.yaml, so you'll want to usecomponent.yamlinstead to determine affected.setting.vendor.context.version: 1.2.3which would overwrite the version, while preserving the rest of the vendor configuration.Why Not Define Vendoring in Stack Configurations?
We deliberately did not add the
vendor.yamlconfigurations to the Stack configurations for a few reasonsvendor.yamlcan import other configs.osterman commentedon May 8, 2024
See: https://atmos.tools/core-concepts/components/vendoring#vendoring-modules-as-components
kevcube commentedon May 8, 2024
Erik Osterman (Cloud Posse) (@osterman) My problem with this is adding potentially hundreds of lines of code to our repo that we have no immediate need to modify. Makes for a large, difficult to actually verify PR.
osterman commentedon May 8, 2024
Kevin (@kevcube) committing the files is not required if using component.yaml, and mitigated from a code review perspective using
.gitattributes.See https://sweetops.slack.com/archives/C031919U8A0/p1714589350835659
Option 1: Vendor and Commit
By default, Cloud Posse (in our engagements and refarch), vendor the everything in to the repositories.
Pros
Cons
Option 2: Vendoring Just In Time
Vendoring components (or anything for that fact, which is supported by atmos) can be done "Just in time", more or less like terraform init for provider and modules.
Pros:
Cons
Option 3: Hybrid
osterman commentedon May 10, 2024
Should components be able to have their own
vendor.yamlthat can be imported?osterman commentedon May 10, 2024
Imagine a
vendor.yamlwith the following.Then in a stack configuration for
devThen in a stack configuration for
prodAnd then running
atmos terraform plan vpc --stack use1-prod-vpc --vendorOr using release channels,
osterman commentedon May 10, 2024
How would overrides pattern work, if you want to use vendoring as proposed?
Note
Monkey patching is an anti-pattern, but is supported
Option 1
Without any signficant changes to atmos, in your vendoring config, ensure you have
Place your
{xxx}_override.tfin the vendored folder and commit only the the_override.tffiles.Option 2
Without any signficant changes to atmos, in your vendoring config, ensure you have:
In this example, local files stored in
components/teraform/overrides/vpc-flow-logs-bucketare copied into the target. As well as a remote providers file is copied in at version1.2.3.You don't have to use
*_override.tf, it could just be*, but it's "safer" to focus on overrides.