Skip to content

Instantly share code, notes, and snippets.

@thegedge
Last active September 16, 2015 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thegedge/dcacba817bfb405afc59 to your computer and use it in GitHub Desktop.
Save thegedge/dcacba817bfb405afc59 to your computer and use it in GitHub Desktop.
Terraform stack layout
// Directory layout
stacks/
|__ us-east-1
|__ test
|__ vpc
|__ services
|__ apps
|__ foo
|__ bar
We have REMOTE files in every directory that's a stack, and a Makefile that finds directories
with a REMOTE file to initialize their remote state appropriately.
// If a module needs a VPC output
resource "terraform_remote_state" "vpc" {
backend = "s3"
config {
bucket = "terraform"
// these vars propagate from the stack to every module
key = "${var.region}/${var.environment}/vpc"
}
}
// If a module needs to know about the NAT or jump hosts
resource "terraform_remote_state" "services" {
backend = "s3"
config {
bucket = "terraform"
// these vars propagate from the stack to every module
key = "${var.region}/${var.environment}/services"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment