Skip to content

Instantly share code, notes, and snippets.

@robinbowes
Created June 29, 2018 21:15
Show Gist options
  • Save robinbowes/20bf2abf8632a6e132400fa4cdd5b084 to your computer and use it in GitHub Desktop.
Save robinbowes/20bf2abf8632a6e132400fa4cdd5b084 to your computer and use it in GitHub Desktop.
Example code for vpc.id problem
module "security_groups" {
source = "./modules/security_groups"
db_port = "${var.db_port}"
identifier = "${local.identifier}"
vpc_id = "${var.vpc_id}"
}
resource "aws_vpc" "vpc" {
cidr_block = "${var.cidr_block}"
tags = {
Name = "${var.name}"
}
}
output "vpc_id" {
value = "${aws_vpc.vpc.id}"
}
data "terraform_remote_state" "vpc" {
backend = "s3"
config {
bucket = "${var.terraform_state_bucket}"
key = "${var.vpc_state_path}"
region = "${var.terraform_state_region}"
}
}
module "netbox" {
source = "git@github.com:acme/terraform.git//modules/services/netbox"
site = "${var.site}"
stage = "${var.stage}"
vpc_id = "${data.terraform_remote_state.vpc.vpc_id}"
db_password = "${var.db_password}"
db_subnet_ids = "${data.terraform_remote_state.vpc.private_subnet_ids}"
}
module "vpc" {
source = "git@github.com:acme/terraform.git//modules/vpc"
cidr_block = "${lookup(local.vpc_data[var.vpc_key], "cidr_block")}"
name = "${lookup(local.vpc_data[var.vpc_key], "name")}"
}
output "vpc_id" {
value = "${module.vpc.vpc_id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment