Optum / dce-cli

Disposable Cloud Environment CLI
Apache License 2.0
37 stars 19 forks source link

Accept TF backend configuration in dce.yml #15

Closed eschwartz closed 4 years ago

eschwartz commented 4 years ago

Would like to be able to provide my own TF backend configuration, and commit it as code to my configuration file

eg

terraform:
  backend:
     type: "S3"
     bucket: "my-bucket"
     key: "terraform.tfstate"
     dynamodb_lock_table: "LockDB"

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.

eschwartz commented 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:

nathanagood commented 4 years ago

See issue #52, where this will be the default method of handling TF state.

nathanagood commented 4 years ago

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.