This repo contains a Terraform Module for retrieving some data from the current account the automation is being applied.
For the basic usage you can include as follows:
module "data" {
source = "diego-alves/data/aws"
version = "0.0.5"
}
Now you can reference the subnet or vcp as module.data.subnet_ids.app
or module.data.vpc_id
.
The basic usage assumes you have a VPC and Subnets with Cloudformation Tag aws:cloudformation:logical-id
, and the values for these tags are:
MainVpc
for the VPC asvpc_id
in the output.AppSubNet1
andAppSubNet1
for the application subnets assubnet_ids.app
in the output.PublicSubNet1
andPublicSubNet1
for the public subnets assubnet_ids.pub
in the output.DBSubNet1
andDBSubNet1
for the data base subnets assubnet_ids.dat
in the output.
If your tag is different, you can specify the variables as follows:
module "data" {
source = "diego-alves/data/aws"
version = "0.0.5"
vpc_logical_id = "MainVPC"
subnet_logical_ids = {
app : ["AppSubNet1", "AppSubNet2"]
pub : ["PublicSubNet1", "PublicSubNet2"]
dat : ["DBSubNet1", "DBSubNet2"]
}
}