From the course: Terraform: Managing Network Infrastructure
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Routing traffic between VPCs using Terraform and VPC peering - Terraform Tutorial
From the course: Terraform: Managing Network Infrastructure
Routing traffic between VPCs using Terraform and VPC peering
- [Instructor] We have a few VPCs now, and we want to route traffic between them. The first option we're going to look at is VPC peering, which is simply a connection between two VPCs. Now, in the real world, you often have to interface with resources in other state files. We know we can reference existing infrastructure by using individual data sources, but sometimes that can be a bit tedious. One really cool data source in Terraform that I personally think is underused and underappreciated is the remote_state data source. This allows me to reference resources in other state files and return their IDs, names, CIDR blocks, or whatever else that I can think of. And we're going to use this in our VPCA configuration to reference the state file in our VPCB configuration. Let's take a look. Now this may seem like overkill for this small use case, but as you scale over time features like this become golden because it reduces the…