Skip to content

Instantly share code, notes, and snippets.

@AkhterAli AkhterAli/locals.tf
Last active Feb 28, 2018

Embed
What would you like to do?
Terraform workspaces with locals
locals {
vpc_type = "${terraform.workspace == "prod" ? "prod" : "dev"}"
vpc_id = "${local.vpc_type == "prod" ? var.vpc_ids["prod"] : var.vpc_ids["dev"]}"
}
resource "aws_subnet" "ext_subnets" {
vpc_id = "${local.vpc_id}"
cidr_block = "${var.ext_subnet_cidr[local.vpc_type]}"
tags {
Name = "EXT_1_${terraform.workspace}"
}
}
vpc_ids = {
prod = "vpc-aad01dd1"
dev = "vpc-f78f568c"
}
ext_subnet_cidr = {
prod = "10.0.0.0/24"
dev = "10.1.0.0/24"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.