Terraform Notes
VPC Data call
Click Here for TF Reference.
In Terraform you can make Data Call to get information about VPC. Few catches, though...
- TF limits you to return only exactly 1 matching VPC
- TF will fail miserable if 0 matching VPC is returned
There are existing arguments, but if you just want the VPC that has a Tag Key, you can do a sub-block of filter.
provider "aws" { region = "us-east-1" profile = "dx" insecure = "true" alias = "dx" } data "aws_vpc" "this" { filter { name="tag-key" values=["SGCatalog"] } provider = aws.dx } locals { VPC_ID = data.aws_vpc.this.id SGCatalogItems = split(",",data.aws_vpc.this.tags.SGCatalog) } module "security_groups" { source = "make_my_security_groups" vpc_id = local.VPC_ID sg = local.SGCatalogItems providers = { aws = aws.dx } }
No comments:
Post a Comment