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

improve tfvars lookup location to include config/stacks/demo/tfvars #336

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

tongueroo
Copy link
Contributor

@tongueroo tongueroo commented Oct 18, 2023

This is a πŸ™‹β€β™‚οΈ feature or enhancement.

  • I've added tests (if it's a bug, feature or enhancement)
  • I've adjusted the documentation (if it's a feature or enhancement)
  • The test suite passes (run bundle exec rspec to verify this)

Summary

Add additional tfvars lookup path at config/stacks/demo/tfvars.

❯ tree config/stacks
config/stacks
└── demo
    └── tfvars
        └── dev.tfvars

Layering is performed in this order:

config/terraform/tfvars/dev.tfvars
app/stacks/demo/tfvars/dev.tfvars
config/stacks/demo/tfvars/dev.tfvars <= NEW

So config/stacks/demo/tfvars/dev.tfvars will take the highest precedence and win.

This allows tfvars config to be decoupled from the stacks. The idea is that stacks can optionally ship with default tfvars files. And users can completely override them without touching the stack code.

This PR also changes terraspace seed so it'll generate the tfvars starter file in config/stacks/demo/tfvars

❯ terraspace seed demo
Seeding tfvar files for demo
      create  config/stacks/demo/tfvars/dev.tfvars

Additionally, found this it easier to see what stacks have been deployed by simply running tree config/stacks

❯ tree config/stacks
config/stacks
└── demo
    └── tfvars
        └── dev.tfvars

How to Test

Just do a sanity check and make sure terraspace works.

Move Script

Here's a useful move-tfvars.rb script that you can use to quickly move your tfvars files from app/stacks to config/stacks.

Also relevant docs: https://terraspace.cloud/docs/layering/tfvars-location-thoughts/

Version Changes

Patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant