Skip to content

Instantly share code, notes, and snippets.

@brainsik
Last active November 16, 2018 01:44
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 brainsik/e67e804a9aa2e90e02ac60e214b52937 to your computer and use it in GitHub Desktop.
Save brainsik/e67e804a9aa2e90e02ac60e214b52937 to your computer and use it in GitHub Desktop.
Takes a list of VPC names and outputs their ID and CIDR
data "aws_vpc" "found" {
count = "${length(var.vpc_names)}"
filter {
name = "tag:Name"
values = ["${element(var.vpc_names, count.index)}"]
}
}
output "vpc_id" {
value = "${formatlist("%21s %s", data.aws_vpc.found.*.id, data.aws_vpc.found.*.cidr_block)}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment