VPC-App Lookup Module
This folder contains a Terraform module which can use data sources to fetch all the data about a VPC created by the
vpc-app
module, including the VPC ID, subnet IDs, route table IDs, NAT Gateway IDs, and so on.
Normally, you can look up this data using either a dependency
block in Terragrunt or a terraform_remote_state
data
source in Terraform, but in some cases, the team that needs the VPC data does not have access to the code or Terraform
state for the VPC module, perhaps because networking is managed by a separate team, maybe in a separate repo.
Therefore, this vpc-app-lookup
module allows you to fetch all the info you need without having to have access to the
code or Terraform state.
This module attempts to match the output variables API of vpc-app
exactly.
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S VPC-APP-LOOKUP MODULE
# ------------------------------------------------------------------------------------------------------
module "vpc_app_lookup" {
source = "git::git@github.com:gruntwork-io/terraform-aws-vpc.git//modules/vpc-app-lookup?ref=v0.28.1"
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# The CIDR block of the VPC you're looking for
cidr_block = null
# Whether the VPC you're looking for is the Default VPC or not
default = null
# The DHCP Options ID fo the VPC you're looking for
dhcp_options_id = null
# Additional filters to use to find the VPC. The key is a unique name for the
# filter (for use with for_each). The value is an object where the names and
# values are those of supported filters from the underlying API:
# https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcs.html.
filters = null
# The ID of the VPC you're looking for
id = null
# If you enabled the default route table and wish to look it up, set this to
# true.
lookup_default_route_table = false
# If you enabled the default security group and wish to look it up, set this
# to true.
lookup_default_security_group = false
# If you enabled the Internet Gateway and wish to look it up, set this to
# true.
lookup_internet_gateway = false
# If you enabled the VPC endpoints and wish to look them up, set this to true.
lookup_vpc_endpoints = false
# The name of the private persistence subnet tier. This is used to identify
# the subnet and its resources.
private_persistence_subnet_name = "private-persistence"
# The name of the private subnet tier. This is used to identify the subnet and
# its resources.
private_subnet_name = "private-app"
# The name of the public subnet tier. This is used to identify the subnet and
# its resources.
public_subnet_name = "public"
# The state of the VPC you're looking for. Can either be 'pending' or
# 'available'.
state = null
# The tags of the VPC you're looking for. Only VPCs that have the exact
# key/value pairs you specify will be matched.
tags = null
# The name of the transit subnet tier. This is used to identify the subnet and
# its resources.
transit_subnet_name = "transit"
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S VPC-APP-LOOKUP MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-vpc.git//modules/vpc-app-lookup?ref=v0.28.1"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# The CIDR block of the VPC you're looking for
cidr_block = null
# Whether the VPC you're looking for is the Default VPC or not
default = null
# The DHCP Options ID fo the VPC you're looking for
dhcp_options_id = null
# Additional filters to use to find the VPC. The key is a unique name for the
# filter (for use with for_each). The value is an object where the names and
# values are those of supported filters from the underlying API:
# https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcs.html.
filters = null
# The ID of the VPC you're looking for
id = null
# If you enabled the default route table and wish to look it up, set this to
# true.
lookup_default_route_table = false
# If you enabled the default security group and wish to look it up, set this
# to true.
lookup_default_security_group = false
# If you enabled the Internet Gateway and wish to look it up, set this to
# true.
lookup_internet_gateway = false
# If you enabled the VPC endpoints and wish to look them up, set this to true.
lookup_vpc_endpoints = false
# The name of the private persistence subnet tier. This is used to identify
# the subnet and its resources.
private_persistence_subnet_name = "private-persistence"
# The name of the private subnet tier. This is used to identify the subnet and
# its resources.
private_subnet_name = "private-app"
# The name of the public subnet tier. This is used to identify the subnet and
# its resources.
public_subnet_name = "public"
# The state of the VPC you're looking for. Can either be 'pending' or
# 'available'.
state = null
# The tags of the VPC you're looking for. Only VPCs that have the exact
# key/value pairs you specify will be matched.
tags = null
# The name of the transit subnet tier. This is used to identify the subnet and
# its resources.
transit_subnet_name = "transit"
}
Reference
- Inputs
- Outputs
Optional
cidr_block
stringThe CIDR block of the VPC you're looking for
null
default
boolWhether the VPC you're looking for is the Default VPC or not
null
dhcp_options_id
stringThe DHCP Options ID fo the VPC you're looking for
null
filters
map(object(…))Additional filters to use to find the VPC. The key is a unique name for the filter (for use with for_each). The value is an object where the names and values are those of supported filters from the underlying API: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcs.html.
map(object({
name = string
values = list(string)
}))
null
id
stringThe ID of the VPC you're looking for
null
If you enabled the default route table and wish to look it up, set this to true.
false
If you enabled the default security group and wish to look it up, set this to true.
false
If you enabled the Internet Gateway and wish to look it up, set this to true.
false
If you enabled the VPC endpoints and wish to look them up, set this to true.
false
The name of the private persistence subnet tier. This is used to identify the subnet and its resources.
"private-persistence"
private_subnet_name
stringThe name of the private subnet tier. This is used to identify the subnet and its resources.
"private-app"
public_subnet_name
stringThe name of the public subnet tier. This is used to identify the subnet and its resources.
"public"
state
stringThe state of the VPC you're looking for. Can either be 'pending' or 'available'.
null
tags
map(string)The tags of the VPC you're looking for. Only VPCs that have the exact key/value pairs you specify will be matched.
null
transit_subnet_name
stringThe name of the transit subnet tier. This is used to identify the subnet and its resources.
"transit"
The ID of the default security group of this VPC.
The IPv6 CIDR block associated with the VPC.
A list of ARNs of the private app subnets in the VPC
The private IP address range of the VPC in CIDR notation.
A list of IDs of the private app subnets in the VPC
A list of IDs of the private app subnet routing table.
A map of all private-app subnets, with the subnet ID as key, and all aws-subnet
properties as the value.
A list of IDs of the private persistence subnet routing table.
DEPRECATED. Use private_persistence_subnet_arns
instead.
The ARNs of the private persistence tier subnets of the VPC.
The private IP address range of the VPC Persistence tier in CIDR notation.
The IDs of the private persistence tier subnets of the VPC.
A list of IDs of the private persistence subnet routing table.
A map of all private-persistence subnets, with the subnet ID as key, and all aws-subnet
properties as the value.
A list of IDs of the private app subnet routing table.
A list of ARNs of the public subnets of the VPC.
The public IP address range of the VPC in CIDR notation.
A list of IDs of the public subnets of the VPC.
The ID of the public routing table.
A list of IDs of the public routing tables.
A map of all public subnets, with the subnet ID as key, and all aws-subnet
properties as the value.
The ARNs of the transit tier subnets of the VPC.
The private IP address range of the VPC transit tier in CIDR notation.
The IDs of the transit tier subnets of the VPC.
A list of IDs of the transit subnet routing table.
A map of all transit subnets, with the subnet ID as key, and all aws-subnet
properties as the value.
The IP address range of the VPC in CIDR notation.
The ID of the VPC.
The name configured for VPC.