Set up an AWS VPC peering connection

Uses: Kong Gateway
Related Documentation
Incompatible with
on-prem
TL;DR

Use the Konnect API to initiate peering, then accept the request in AWS and update your route table.

Prerequisites

This is a Konnect tutorial that requires Dedicated Cloud Gateways access.

If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.

  1. The following Konnect items are required to complete this tutorial:
    • Personal access token (PAT): Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
    • Dedicated Cloud Gateway Control Plane Dedicated Cloud Gateway: You can use an existing Dedicated Cloud Gateway or create a new one to use for this tutorial.
    • Network ID: The default Dedicated Cloud Gateway network ID can be found in Gateway Manager > Network
  2. Set these values as environment variables:
     export KONNECT_TOKEN='YOUR KONNECT TOKEN'
     export KONNECT_CONTROL_PLANE_URL=https://us.api.konghq.com
     export KONNECT_NETWORK_ID='KONNECT NETWORK ID'
    

You’ll need:

Save these values:

export AWS_ACCOUNT_ID='123456789012'
export AWS_VPC_ID='vpc-0f1e2d3c4b5a67890'
export AWS_REGION='us-east-2'
export AWS_VPC_CIDR='10.1.0.0/16'

Initiate the VPC peering connection

Send the following request to the Cloud Gateways API:

curl -X POST "https://global.api.konghq.com/v2/cloud-gateways/networks/$KONNECT_NETWORK_ID/transit-gateways" \
     -H "Authorization: Bearer $KONNECT_TOKEN"\
     -H "Accept: application/json"\
     -H "Content-Type: application/json" \
     --json '{
       "name": "us-east-2 vpc peering",
       "cidr_blocks": [
         "'$AWS_VPC_CIDR'"
       ],
       "transit_gateway_attachment_config": {
         "kind": "aws-vpc-peering-attachment",
         "peer_account_id": "'$AWS_ACCOUNT_ID'",
         "peer_vpc_id": "'$AWS_VPC_ID'",
         "peer_vpc_region": "'$AWS_REGION'"
       }
     }'

Accept the peering request in AWS

  1. Go to the AWS Console → VPCVPC Peering Connections.
  2. Locate the pending request from Konnect.
  3. Select the request and from the Actions menu, select Accept request.

Update your AWS route table

  1. In the AWS Console, go to VPCRoute Tables.
  2. Select the route table for your VPC’s subnet.
  3. Select Edit routes from the Actions menu.
  4. Click Add route, and enter the following:
    • Destination: The CIDR block of the Konnect network.
    • Target: The accepted VPC peering connection.
  5. Save your changes.

This ensures private traffic routing between your VPC and the Dedicated Cloud Gateway.

Validation

To validate that everything was configured correctly, issue a GET request to the /transit-gateways endpoint to retrieve VPC peering information:

curl -X GET "https://global.api.konghq.com/v2/cloud-gateways/networks/$KONNECT_NETWORK_ID/transit-gateways" \
     -H "Authorization: Bearer $KONNECT_TOKEN"
Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!