Closed eschwartz closed 4 years ago
How do we keep our local backend (terraform.tfstate
file)?
Need to move away from using temp directories for terraform module.
For one, we can simplify our terraform module code generation, to something just like:
// Backend configuration
terraform {
// Generated from TF backend config in dce.yml
backend "local" {
path = "relative/path/to/terraform.tfstate"
}
}
// Load DCE TF module from github
module "dce" {
source="github.com/Optum/dce//terraform?ref=v0.23.0"
// TF params, generated from dce.yml, or CLI flags
budget_notification_emails = ["jdoe@exampl.com"]
}
Then, the question is where to put that generated code. Our local tfstate file will be generated in the same directory. We don't want to put it in a temp dir, because then we'll lose our statefile.
I'd say we either:
~/.dce/config.yml
), and then put the module there (eg. ~/.dce/terraform/main.tf
)See issue #52, where this will be the default method of handling TF state.
This should stay open. It's part 2 of a 2-part solution to a feature request: 1.) use local TF state by default and then 2.) accept a configuration from the YML file. See #52 for part 1.
Would like to be able to provide my own TF backend configuration, and commit it as code to my configuration file
eg
Also, If the DCE CLI creates a TF backend for me, it should update the dce.yml file with the backend configuration, so it can be reused as committed as code.