Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-iconexamples
file-type-iconmodules
file-type-icon_docs
file-type-iconnetwork-acl-inbound
file-type-iconnetwork-acl-outbound
file-type-iconport-range-calculator
file-type-iconvpc-app-network-acls
file-type-iconvpc-app
file-type-iconvpc-dns-forwarder-rules
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconvariables.tf
file-type-iconvpc-dns-forwarder
file-type-iconvpc-flow-logs
file-type-iconvpc-interface-endpoint
file-type-iconvpc-mgmt-network-acls
file-type-iconvpc-mgmt
file-type-iconvpc-peering-cross-accounts-accepter
file-type-iconvpc-peering-cross-accounts-requester
file-type-iconvpc-peering-external
file-type-iconvpc-peering
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.md
file-type-iconterraform-cloud-enterprise-private-module-...

Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-iconexamples
file-type-iconmodules
file-type-icon_docs
file-type-iconnetwork-acl-inbound
file-type-iconnetwork-acl-outbound
file-type-iconport-range-calculator
file-type-iconvpc-app-network-acls
file-type-iconvpc-app
file-type-iconvpc-dns-forwarder-rules
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconvariables.tf
file-type-iconvpc-dns-forwarder
file-type-iconvpc-flow-logs
file-type-iconvpc-interface-endpoint
file-type-iconvpc-mgmt-network-acls
file-type-iconvpc-mgmt
file-type-iconvpc-peering-cross-accounts-accepter
file-type-iconvpc-peering-cross-accounts-requester
file-type-iconvpc-peering-external
file-type-iconvpc-peering
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.md
file-type-iconterraform-cloud-enterprise-private-module-...
Virtual Private Cloud (VPC)

Virtual Private Cloud (VPC)

Create a Virtual Private Cloud (VPC). Includes multiple subnet tiers, NACLs, NAT gateways, Internet Gateways, and VPC peering.

Code Preview

Preview the Code

mobile file icon

README.md

down

VPC DNS Forwarder Rules Terraform Module

This Terraform Module creates Route 53 Resolver Forwarding Rules for a VPC that will utilize Route 53 Resolver Endpoints created with the vpc-dns-forwarder module. These forwarding rules, combined with Route 53 Resolvers, allow DNS queries for specific domains to be resolved by peered VPCs.

How do you use this module?

Check out the vpc-peering example that shows how to use this module to forward DNS queries from a management VPC to an app VPC.

How do you specify the hostnames that use the forwarder?

By default, no DNS query will be routed through the Route 53 Resolvers created by the vpc-dns-forwarder module. You need to create forwarding rules that specify which specific domains should be resolved through the Route 53 Resolvers so that they are resolved over the peering connection. You can use this module to construct the forwarding rules.

For example, suppose you had a Route 53 private hosted zone whose domain (we will assume this is test.local) is only available in the peered VPC. The following module calls will construct the forwarder rules so that DNS queries for the domain in the peering VPC will be routed through the resolvers to be resolved in the peered VPC:

module "dns_mgmt_to_app" {
  source = "git::git@github.com:gruntwork-io/terraform-aws-vpc.git//modules/vpc-dns-forwarder?ref=v0.5.7"

  # Arguments omitted for brevity
}

module "dns_forwarder_rule" {
  source = "git::git@github.com:gruntwork-io/terraform-aws-vpc.git//modules/vpc-dns-forwarder-rules?ref=v0.5.7"

  vpc_id                                        = "${module.mgmt_vpc.vpc_id}"
  origin_vpc_route53_resolver_endpoint_id       = "${module.dns_mgmt_to_app.origin_vpc_route53_resolver_endpoint_id}"
  destination_vpc_route53_resolver_primary_ip   = "${module.dns_mgmt_to_app.destination_vpc_route53_resolver_primary_ip}"
  destination_vpc_route53_resolver_secondary_ip = "${module.dns_mgmt_to_app.destination_vpc_route53_resolver_secondary_ip}"

  num_endpoints_to_resolve = 1
  endpoints_to_resolve     = ["test.local"]
}

This will create a forwarding rule such that any DNS query for test.local originating in the mgmt_vpc will be routed through the created resolvers and resolved in the app_vpc.

NOTE: The forwarder endpoints use a domain suffix based match. For example, if you specify the endpoint local in the forwarder rule, it will match any domain that ends with .local (note the dot), but does not match a domain like test.alblocal.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?