Skip to main content
VPC Modules 0.27.0Last updated in version 0.26.21

VPC-App Lookup Module

View Source Release Notes

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

main.tf

# ------------------------------------------------------------------------------------------------------
# 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.27.0"

# ----------------------------------------------------------------------------------------------------
# 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

Optional

cidr_blockstringoptional

The CIDR block of the VPC you're looking for

null
defaultbooloptional

Whether the VPC you're looking for is the Default VPC or not

null
dhcp_options_idstringoptional

The DHCP Options ID fo the VPC you're looking for

null
filtersmap(object(…))optional

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
idstringoptional

The 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_namestringoptional

The name of the private subnet tier. This is used to identify the subnet and its resources.

"private-app"
public_subnet_namestringoptional

The name of the public subnet tier. This is used to identify the subnet and its resources.

"public"
statestringoptional

The state of the VPC you're looking for. Can either be 'pending' or 'available'.

null
tagsmap(string)optional

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_namestringoptional

The name of the transit subnet tier. This is used to identify the subnet and its resources.

"transit"