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 helper functions for remote state #12770

Open
mbainter opened this issue Mar 16, 2017 · 1 comment
Open

Add helper functions for remote state #12770

mbainter opened this issue Mar 16, 2017 · 1 comment

Comments

@mbainter
Copy link
Contributor

mbainter commented Mar 16, 2017

The new remote state functionality in 0.9 is interesting, but leaves me (and presumably others) in a somewhat unfortunate situation. To minimize the number of things touched in a terraform run we group things logically across a somewhat sprawling directory structure. Our remote state and locking setup mirrors these same paths.

I was already using similar functionality from the "terragrunt" wrapper tool, which also provides me with two very useful helper functions for managing those remote state details called "find_in_parent_folders()" and "path_relative_to_include()". Working together, these functions establish the path between the root of the terraform tree and this one, giving me a relative path to use for the key details in each of my terraform configuration directories. That means the configuration only has to be applied once (in the root) and everywhere else I can just copy the basic configuration.

Without this, the configuration has to be constructed manually each time which is an error-prone practice. It looks like the new state code has checks to make sure you don't accidentally overwrite a statefile with a different lineage (thank you for that) but it would still be nice to avoid this repetitive work with a similar capability in core.

@holybit
Copy link

holybit commented Apr 1, 2017

Hear, hear! This would be a great enhancement for S3 backend users. I get that Terraform has more backends than just "S3." But if your using S3 backend currently you end up with little init.sh scripts or makefile strewn throughout your repo to set the S3 key path. It's anti DRY and KISS.

A top level config for an S3 backend for this feature might look like this:

terraform {
  backend "s3" {
    bucket = "mybucket"
    key    = "auto-tree"
    region = "us-east-1"
  }
}

A key value of auto-tree would tell Terraform to determine pwd and set it as key value. Feel free to bike shed auto-tree or expand and refine the basic Terragrunt config concept.

@apparentlymart apparentlymart added cli and removed core labels Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants