AWS Builder Center
AWS VPC Lattice Hands-on Guide: Connecting Applications Across VPCs Without Transit Gateway or VPC Peering (Part 1)

AWS VPC Lattice Hands-on Guide: Connecting Applications Across VPCs Without Transit Gateway or VPC Peering (Part 1)

In this hands-on guide, we'll explore Amazon VPC Lattice by building a complete working solution from scratch. You'll learn how to securely connect applications running in two isolated VPCs without configuring VPC Peering or Transit Gateway. Starting with two independent VPCs, we'll deploy a web application on Amazon EC2, create a VPC Lattice Target Group, Service, and Service Network, and finally enable secure service-to-service communication using the VPC Lattice DNS endpoint.

Series: Building Modern Application Networking with Amazon VPC Lattice (2 articles)

  1. 1
    AWS VPC Lattice Hands-on Guide: Connecting Applications Across VPCs Without Transit Gateway or VPC Peering (Part 1) This article
Community Builder and Browserstack Champion

Introduction

Modern cloud applications are no longer built as a single monolithic application. Instead, they consist of multiple microservices deployed across different VPCs, AWS accounts, and environments such as Development, Testing, and Production.
Traditionally, organizations relied on VPC Peering or AWS Transit Gateway to establish communication between these VPCs. While these services provide network connectivity, they also introduce additional complexity around route tables, attachments, and security management.
AWS introduced Amazon VPC Lattice to simplify service-to-service communication by focusing on application networking rather than network connectivity.
In this blog, we'll build a simple VPC Lattice environment from scratch and understand how applications can communicate securely across isolated VPCs without configuring Transit Gateway or VPC Peering.



What We'll Build

Our architecture consists of two isolated VPCs.




Prerequisites

Before starting, ensure you have:
  • AWS Account
  • IAM permissions to create VPCs and EC2
  • Basic understanding of EC2 and VPC
  • Region: us-east-1 (used in this walkthrough)

Step 1 – Create Two VPCs

We first create two completely isolated VPCs
VPC
CIDR
Purpose
Provider-VPC
10.0.0.0/16
Hosts the application
Consumer-VPC
10.1.0.0/16
Accesses the application
Each VPC contains one public subnet.
Provider Subnet
10.0.1.0/24
Consumer Subnet
10.1.1.0/24
At this stage, there is no communication between these VPCs.
VPCs


Step 2 – Configure Internet Connectivity

To access EC2 instances, we configured:
  • Internet Gateway
  • Route Table
  • Public Subnet Association
  • Auto Assign Public IP
Each subnet now has internet connectivity.

Step 3 – Launch EC2 Instances

Next, we launched two EC2 instances.

Provider EC2

Purpose:
Hosts our web application.
Configuration:
  • Amazon Linux 2023
  • t2.micro
  • Provider VPC



Consumer EC2

Purpose:
Acts as the client machine.
Configuration:
  • Amazon Linux 2023
  • t2.micro
  • Consumer VPC


EC2


Step 4 – Install Nginx

On the Provider EC2, install Nginx.
sudo dnf update -y
sudo dnf install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx
Verify:
sudo systemctl status nginx
You should see:
active (running)
nginx server


Step 5 – Deploy a Sample Web Page

Replace the default index page.
echo '<h1>Hello from Provider VPC using VPC Lattice!</h1>' \
| sudo tee /usr/share/nginx/html/index.html
Verify:
curl localhost
Output
<h1>Hello from Provider VPC using VPC Lattice!</h1>

Step 6 – Verify Traditional Access

Allow HTTP (Port 80) in the Security Group.
Open the browser.
http://<Public-IP>
Result
Hello from Provider VPC using VPC Lattice!
This represents the traditional architecture where applications are accessed directly using a Public IP.
Internet

↓

Public IP

↓

EC2

↓

Application
While simple, this exposes the application publicly and tightly couples clients to server IP addresses.

Step 7 – Create a VPC Lattice Target Group

Next, create a Target Group.
Purpose:
The Target Group tells VPC Lattice where the application is running.
Configuration
Setting
Value
Target Type
Instance
Protocol
HTTP
Port
80
Register:
Provider-WebServer
Important: Register the EC2 instance as a target. If no targets are registered, VPC Lattice returns:
503 Service Unavailable
This was an issue we encountered during our implementation.
target group


Step 8 – Create a VPC Lattice Service

Create a new service.
Configuration
Property
Value
Authentication
None
Listener
HTTP
Port
80
Associate the Target Group.
AWS automatically generates a DNS name similar to:
provider-web-service-xxxx.vpc-lattice-svcs.us-east-1.on.aws
Applications will use this DNS instead of the EC2 Public IP.
vpc lattice


Step 9 – Create a Service Network

Create a Service Network.
demo-service-network
Associate:
  • Provider-Web-Service
Then associate both:
  • Provider-VPC
  • Consumer-VPC
This allows both VPCs to participate in the same application network without configuring Transit Gateway or VPC Peering.
service network


Step 10 – Test Connectivity

SSH into the Consumer EC2.
Instead of using the Public IP, run:
curl http://<VPC-Lattice-Service-DNS>
Output
<h1>Hello from Provider VPC using VPC Lattice!</h1>
At this point, the Consumer VPC successfully communicates with the Provider application through VPC Lattice.
consumer EC2

AWS Account
us-east-1 Region
│
┌────────────────┴────────────────┐
│ │
▼ ▼
Provider-VPC Consumer-VPC
(10.0.0.0/16) (10.1.0.0/16)
│ │
▼ ▼
Provider-WebServer Consumer EC2
(Nginx) │
│ │
▼ │
Target Group │
│ │
▼ │
Provider-Web-Service │
│ │
└──────────────┬──────────────────┘
▼
demo-service-network
│
AWS VPC Lattice



Architectural Diagram





Traditional Networking vs VPC Lattice

Traditional

Client

↓

Public IP

↓

EC2
The client directly knows the server IP.



VPC Lattice

Consumer EC2

↓

VPC Lattice Service

↓

Target Group

↓

Provider EC2
The client knows only the service, not the server.
This abstraction simplifies application connectivity and enables centralized routing and security.



Challenges We Faced

During implementation, we encountered a few common issues:

Missing HTTP Rule

Initially, the application wasn't accessible because the Security Group allowed only SSH. Adding an HTTP (80) inbound rule resolved the issue.

Bash "event not found"

While updating the HTML page, the  !  character triggered Bash history expansion. Using single quotes fixed the problem.

503 Service Unavailable

The VPC Lattice service returned a 503 error because the Target Group was created without registering the EC2 instance. Registering the target and waiting for a healthy status resolved the issue.
These troubleshooting steps are useful for anyone implementing VPC Lattice for the first time.



Key Takeaways

  • VPC Lattice focuses on application connectivity, not network connectivity.
  • Applications communicate using a service DNS rather than server IP addresses.
  • No Transit Gateway or VPC Peering was required.
  • Service Networks simplify connectivity across isolated VPCs.
  • Target Groups provide health checks and backend management.
  • Consumers remain unaware of the underlying infrastructure.



What's Next?

In Part 2, we'll make this architecture more secure by exploring VPC Lattice's Zero Trust capabilities.
We'll cover:
  • IAM Authentication
  • Security Groups on VPC Associations
  • Authorization Policies
  • Access control experiments
  • Comparison with AWS Transit Gateway



Conclusion

AWS VPC Lattice changes the way applications communicate in AWS by shifting the focus from network-to-network connectivity to service-to-service connectivity. Instead of exposing applications through Public IPs or building complex network topologies, VPC Lattice provides a managed application networking layer with service discovery, health checks, and centralized access control.
In this hands-on guide, we built a working VPC Lattice environment from scratch, connected two isolated VPCs, and accessed an application using a VPC Lattice service DNS—all without Transit Gateway or VPC Peering. This forms a strong foundation for implementing modern, secure, and scalable application networking architectures on AWS.

Series: Building Modern Application Networking with Amazon VPC Lattice (2 articles)

  1. 1
    AWS VPC Lattice Hands-on Guide: Connecting Applications Across VPCs Without Transit Gateway or VPC Peering (Part 1) This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article