Automate the setup of inter-Region peering with AWS Transit Gateway
Ram Kandaswamy, Amazon Web Services
Summary
AWS Transit Gateway connects virtual private clouds (VPCs) and on-premises networks through a central hub. Transit Gateway traffic doesn't traverse the public internet, which reduces threat vectors, such as common exploits and distributed denial of service (DDoS) attacks.
If you need to communicate between two or more AWS Regions, you can use inter-Region Transit Gateway peering to establish peering connections between transit gateways in different Regions. However, manually configuring inter-Region peering with Transit Gateway can be a complex and time-consuming. This pattern provides guidance for using infrastructure as code (IaC) to set up peering. You can use this approach if you have to repeatedly configure several Regions and AWS accounts for a multi-Region organization setup.
This pattern sets up an AWS CloudFormationstack that includes an AWS Step Functions workflow, AWS Lambda functions, AWS Identity and Access Management (IAM) roles, and log groups in Amazon CloudWatch Logs. You then run the Step Functions workflow to create the inter-Region peering connection for your transit gateways.
Prerequisites and limitations
Prerequisites
An active AWS account.
An IDE that has code-generation capability, such as Kiro
. An Amazon Simple Storage Service (Amazon S3) bucket and permissions to upload objects to it.
Transit gateways created in the requesting and accepting Regions.
VPCs created in the requesting and accepting Regions. Tag the VPCs with an
addToTransitGatewaykey with a value oftrue.Security groups configured for your VPCs according to your requirements.
Network access control lists (ACLs) configured for your VPCs according to your requirements.
Limitations
Only some AWS Regions support inter-Region peering. For a full list of Regions that support inter-Region peering, see the AWS Transit Gateway FAQs
.
Architecture
The agentic AI development approach described in this pattern involves the following steps:
Define the automation prompt – Kiro receives a natural language prompt that details the peering requirements.
Generate automation script – Kiro generates the CloudFormation and Lambda scripts based on the provided prompt.
Deploy the stack – Kiro uses CloudFormation to deploy the required resources.
Set up peering – Kiro runs the Step Functions workflow, which calls Lambda functions to create peering connections and modify route tables.
The following diagram shows the Step Functions workflow:

The workflow contains the following steps:
The Step Functions workflow calls the Lambda function for the Transit Gateway peering.
The workflow waits for one minute.
The workflow retrieves the peering status and sends it to the condition block. The block is responsible for the looping.
If the success condition is not met, the workflow is coded to enter the timer stage.
If the success condition is met, a Lambda function modifies the route tables.
The Step Functions workflow ends.
Tools
AWS CloudFormation helps you set up AWS resources, provision them quickly and consistently, and manage them throughout their lifecycle across AWS accounts and AWS Regions.
Amazon CloudWatch Logs helps you centralize the logs from all your systems, applications, and AWS services so you can monitor them and archive them securely.
AWS Identity and Access Management (IAM) helps you securely manage access to your AWS resources by controlling who is authenticated and authorized to use them.
Kiro
is an agentic AI development tool that helps you build production-ready applications through spec-driven development. AWS Lambda is a compute service that helps you run code without needing to provision or manage servers. It runs your code only when needed and scales automatically, so you pay only for the compute time that you use.
AWS Step Functions is a serverless orchestration service that helps you combine AWS Lambda functions and other AWS services to build business-critical applications.
Epics
| Task | Description | Skills required |
|---|---|---|
Filling prompt placeholders with specific details |
NoteAlternatively, you can add this as an inline prompt that references the above variables without attaching the file for context. | General AWS, Network administrator |
Create a Lambda function that creates the peering attachments. |
| General AWS, Network administrator, Prompt engineering |
Create a Lambda function that polls the peering attachment status. |
| General AWS, Network administrator, Prompt engineering |
Create a Lambda function that adds static routes to both Regions. |
| General AWS, Network administrator |
Create the CloudFormation template. |
| AWS DevOps, General AWS, Prompt engineering |
| Task | Description | Skills required |
|---|---|---|
Deploy the CloudFormation stack by using prompts. | Enter the following prompt:
| AWS DevOps, Cloud administrator, General AWS, Prompt engineering |
Validate deployment. |
| General AWS |