---
title: "Configure AWS VPC peering"
description: "Step-by-step guide to configuring AWS VPC peering for private, secure connectivity to Aerospike Cloud databases."
---

# Configure AWS VPC peering

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

With VPC peering, your app running in your AWS VPC can communicate privately with an Aerospike Cloud database in the Aerospike Cloud VPC without traversing the public internet. VPC peering reduces latency and exposure, ensuring a more secure connection for your applications.

## Prerequisites

-   The AWS CLI is installed and configured.
    
-   An existing AWS VPC with an IPv4 CIDR block that does not overlap with any of the following:
    
    -   The CIDR block of the specific cluster you are peering with. Aerospike Cloud assigns this at provisioning as either an auto-generated value or a custom value you specify. Find it on the cluster **Details** tab → **Infrastructure** section → **CIDR block** field.
        
    -   The internal services CIDR `10.129.0.0/24`.
        
    -   The CIDR block of any other VPC peering connection to the same Aerospike Cloud cluster that is active, pending, or being created.
        
-   Basic familiarity with [AWS VPC peering](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html).
    
-   _DNS hostnames_ and _DNS resolution_ are enabled in your VPC attributes.
    

::: tip
Have your _`AWS VPC ID`_, _`AWS VPC CIDR`_, _`AWS Account ID`_, and _`AWS Region`_ ready. Aerospike Cloud automates its side of the connection. You use these values to initiate and configure the connection from your AWS account.
:::

## Configure VPC peering

Complete these steps to peer your AWS VPC with Aerospike Cloud and configure routing, DNS, security groups, and connectivity.

### Step 1: Create or identify your AWS VPC

Prepare your AWS VPC and collect the identifiers you need for the peering request.

1.  Create a new VPC in AWS or verify your existing VPC.
    
2.  Verify that the CIDR block does not overlap with the Aerospike Cloud CIDR blocks listed in the prerequisites.
    
3.  Record the following details for your VPC:
    
    -   VPC ID (for example, `vpc-0abcd1234efgh5678`)
    -   CIDR block (for example, `10.0.0.0/16`)
    -   AWS account ID (for example, `123456789012`)
    -   AWS Region (for example, `us-east-1`)

### Step 2: Initiate VPC peering

Request a peering connection from the Aerospike Cloud Console or API.

-   [Aerospike Cloud Console](#tab-panel-3682)
-   [Aerospike Cloud API](#tab-panel-3683)

1.  Open your cluster and go to the **Networking** tab → **VPC peering**.
    
2.  Click **Create VPC Peering**.
    
3.  Fill in the details of your AWS VPC:
    
    -   **AWS Account ID**: The 12-digit ID of your AWS account where your VPC resides.
    -   **AWS Region**: The AWS region of your VPC.
    -   **VPC ID**: The identifier of your VPC (for example, `vpc-0abcd1234efgh5678`).
    -   **VPC CIDR**: Your VPC’s IPv4 CIDR block (for example, `10.0.0.0/16`).
4.  Submit the peering request.
    

1.  Create a VPC peering request:
    
    Terminal window
    
    ```bash
    curl -X POST "https://api.aerospike.com/v1/database/clusters/{clusterId}/vpc-peerings" \
    
      -H "Authorization: Bearer YOUR_TOKEN" \
    
      -H "Content-Type: application/json" \
    
      -d '{
    
        "vpcId": "YOUR_AWS_VPC_ID",
    
        "cidrBlock": "YOUR_AWS_VPC_CIDR",
    
        "accountId": "YOUR_AWS_ACCOUNT_ID",
    
        "region": "YOUR_AWS_REGION",
    
        "isSecureConnection": true
    
      }'
    ```
    
2.  Check the peering status:
    
    Terminal window
    
    ```bash
    curl -X GET "https://api.aerospike.com/v1/database/clusters/{clusterId}/vpc-peerings" \
    
      -H "Authorization: Bearer YOUR_TOKEN"
    ```
    
    The response is a paginated collection. Each item in `vpcPeerings` describes one connection. Note the `status` field, for example `initiating-request`, `pending-acceptance`, or `active`.
    
    ```json
    {
    
      "count": 1,
    
      "meta": null,
    
      "vpcPeerings": [
    
        {
    
          "id": "902aafd0-b46c-4f7b-a622-80e447c439ad",
    
          "accountId": "123456789012",
    
          "vpcId": "vpc-0abcd1234efgh5678",
    
          "cidrBlock": "10.0.0.0/16",
    
          "region": "us-east-1",
    
          "status": "initiating-request",
    
          "peeringId": "pcx-1410263943e464f4a",
    
          "isSecureConnection": true,
    
          "isRequester": true
    
        }
    
      ]
    
    }
    ```
    

::: what happens next?
Aerospike Cloud creates a peering connection request. The connection status reads _Pending Acceptance_ until you accept it in your AWS account.
:::

### Step 3: Accept the peering request

Since Aerospike Cloud initiated the peering request, you must accept it in your AWS account.

-   [AWS Console](#tab-panel-3684)
-   [AWS CLI](#tab-panel-3685)

1.  Navigate to **VPC** → **Peering Connections**.
    
2.  Select the pending peering connection containing your peering connection ID.
    
3.  Select **Actions** → **Accept request**.
    

Accept the peering connection:

Terminal window

```bash
aws ec2 accept-vpc-peering-connection \

  --vpc-peering-connection-id YOUR_VPC_PEERING_CONNECTION_ID \

  --region YOUR_AWS_REGION
```

### Step 4: Update route tables

To route traffic from your VPC to the Aerospike Cloud database VPC, add route table entries in your VPC route tables.

Locate the route tables for each subnet that requires Aerospike access and add a route table entry to each one.

Each route table entry should include the following:

-   **Destination** (Aerospike cluster CIDR): The cluster **CIDR block** from the **Details** tab → **Infrastructure** section.
-   **Target**: The VPC peering connection ID, for example `pcx-1410263943e464f4a`

-   [AWS Console](#tab-panel-3686)
-   [AWS CLI](#tab-panel-3687)

1.  In **VPC** → **Route Tables**, locate the route tables for subnets that require Aerospike access.
    
2.  Add a route to each required route table with:
    
    -   **Destination** (Aerospike cluster CIDR): Enter the cluster **CIDR block** from the **Details** tab → **Infrastructure** section.
    -   **Target**: The VPC peering connection ID, for example `pcx-1410263943e464f4a`

Create the route table entry:

Terminal window

```bash
aws ec2 create-route \

  --region YOUR_AWS_REGION \

  --route-table-id YOUR_ROUTE_TABLE_ID \

  --destination-cidr-block YOUR_AEROSPIKE_CLUSTER_CIDR \

  --vpc-peering-connection-id YOUR_VPC_PEERING_CONNECTION_ID
```

### Step 5: Associate private hosted zone (DNS)

Associate your VPC with Aerospike’s private hosted zone so database endpoints resolve to private IPs inside your network.

::: mandatory step
DNS association is required to resolve Aerospike database endpoints. Verify that `enableDnsSupport` and `enableDnsHostnames` are set to `true` in your VPC settings. These settings appear as _DNS hostnames_ and _DNS resolution_ in the AWS VPC Console.
:::

1.  After the peering connection is accepted, get the hosted zone ID associated with your Aerospike Cloud database.
    
    -   [Aerospike Cloud Console](#tab-panel-3680)
    -   [Aerospike Cloud API](#tab-panel-3681)
    
    The hosted zone ID, for example `Z04089311NGVVH0FO3QGG`, is shown in the **Infrastructure** section of the **Details** tab of your Aerospike Cloud database.
    
    Get the hosted zone ID from the cluster’s `infrastructure.hostedZoneId` field:
    
    Terminal window
    
    ```bash
    curl -X GET "https://api.aerospike.com/v1/database/clusters/{clusterId}" \
    
      -H "Authorization: Bearer YOUR_TOKEN"
    ```
    
    The response includes a `hostedZoneId` field nested under `infrastructure`, for example:
    
    ```json
    {
    
      "infrastructure": {
    
        "hostedZoneId": "Z04089311NGVVH0FO3QGG",
    
        ...
    
      },
    
      ...
    
    }
    ```
    
2.  Associate your VPC with Aerospike’s private hosted zone.
    
    ::: note
    You can only perform this action with the AWS CLI, as the hosted zone is owned by an Aerospike Cloud AWS Account.
    :::
    
    Terminal window
    
    ```bash
    aws route53 associate-vpc-with-hosted-zone \
    
      --hosted-zone-id HOSTED_ZONE_ID \
    
      --vpc VPCRegion=YOUR_AWS_REGION,VPCId=YOUR_AWS_VPC_ID
    ```
    
3.  After a few minutes, DNS queries in your VPC, for example `fcd8461a-49ee-42ea-ae08-7366a94e7654.aerospike.internal`, resolve to Aerospike’s private IP addresses.
    

### Step 6: Configure security groups

Follow these guidelines for configuring security groups in your VPC:

1.  Add outbound rules that allow traffic on the following ports to the cluster CIDR block (from the **Details** tab → **Infrastructure** section):
    
    -   TCP port 4000 for TLS client connections
    -   (Optional) TCP port 9145 to the [Aerospike Prometheus Exporter](https://aerospike.com/docs/database/observe/monitor/components#aerospike-prometheus-exporter) metrics port
2.  Do not add an inbound rule that explicitly allows traffic from the Aerospike VPC block. Since security groups are stateful, if an instance in your VPC initiates a connection to the Aerospike VPC, the return traffic is automatically allowed back in.
    

::: note
The Aerospike Cloud VPC is automatically configured to allow inbound traffic from peered VPCs and has outbound rules configured to ensure proper return traffic to your VPC.
:::

### Step 7: Test connectivity

Run the following from a host in your peered AWS VPC (for example, an EC2 instance or a pod). Commands do not work from your laptop unless it has network access to that VPC.

1.  In the Aerospike Cloud console, open **Clusters**, select your cluster, and open the **Details** tab. In the **Connection** section, copy **Hostname**.
    
    Use the full value (for example, `a1b2c3d4-e5f6-7890-abcd-ef1234567890.aerospike.internal`) as _`HOSTNAME`_ in the following steps. **TLS port** in the same section is `4000`.
    
    For `--tls-name`, use the full **Hostname** value, not the bare **Cluster ID** from the **General** section.
    
2.  Test DNS resolution. The following commands should return a list of private IPs, one for each Aerospike node:
    
    Terminal window
    
    ```bash
    dig +short HOSTNAME
    ```
    
    Or:
    
    Terminal window
    
    ```bash
    getent hosts HOSTNAME
    ```
    
    Use one of the returned addresses as _`NODE_IP`_ for the TCP connectivity test.
    
3.  Test TCP connectivity to the TLS port on a node IP from the previous step:
    
    Terminal window
    
    ```bash
    nc -zv NODE_IP 4000
    ```
    
    If `nc` is unavailable:
    
    Terminal window
    
    ```bash
    timeout 3 bash -c 'cat < /dev/null > /dev/tcp/NODE_IP/4000' \
    
      && echo "4000 open" || echo "4000 closed"
    ```
    
    If port `4000` is closed, double-check route tables, peering acceptance, and security group outbound rules from [step 6](#step-6-configure-security-groups).
    
4.  (Optional) Connect with [Aerospike Quick Look (AQL)](https://aerospike.com/docs/database/tools/aql/).
    
    Before running AQL:
    
    -   [Install tools on Linux from a package manager](https://aerospike.com/docs/database/tools/install/package-managers/) on the test host.
    -   [Create a database user](https://aerospike.com/docs/cloud/manage/database-users/) with the roles you need.
    -   On the **Details** tab, in the **Certificates** section, download or copy **TLS certificate** (save as a `.pem` file).
    
    Connect with TLS (port `4000`). Use the same _`HOSTNAME`_ for `-h`, `--tls-name`, and the host in the connection string:
    
    Terminal window
    
    ```bash
    aql --tls-enable \
    
      --tls-name HOSTNAME \
    
      --tls-cafile PATH_TO_CA_PEM \
    
      -h HOSTNAME:4000 \
    
      -U DB_USERNAME \
    
      -P
    ```
    
    Enter the database user password when prompted. For more command options, see [Run Aerospike Quick Look](https://aerospike.com/docs/database/tools/aql/run-aql).
    
    ::: note
    If you see “Peers not reachable”, run AQL from inside the peered VPC. AQL discovers cluster peers and connects to node private IPs directly.
    :::
    

## VPC peering status definitions

Throughout the VPC peering process, Aerospike Cloud and AWS indicate the status of the peering connection. Following are common statuses and their meanings:

-   _Pending Acceptance_: The peering connection request has been created by Aerospike and is awaiting your acceptance in AWS. You must accept the request within seven days or it expires.
-   _Active_: The peering connection is fully established. An active status on both sides means the link is ready for use (though you may still need to configure routing and DNS as described in [step 4](#step-4-update-route-tables) and [step 5](#step-5-associate-private-hosted-zone-dns)).
-   _Provisioning_: (Transient state) The request was accepted and AWS is in the process of making it active. This status usually changes to Active within a few minutes without further action.
-   _Failed_: The peering request failed to establish. This can happen due to invalid parameters or network overlaps. A failed connection cannot be accepted or used. You may need to delete it and create a new request.
-   _Rejected_: The peering request was explicitly declined by the accepter (your side). No connection is made. You would need to create a new request if you rejected by mistake.
-   _Expired_: The request wasn’t accepted within the allowed time (seven days). The connection is not made and the request must be recreated if still needed.

In the Aerospike Cloud Console, these statuses may be labeled slightly differently (for example, _Pending_ instead of _Pending Acceptance_) but the status is unchanged. _Active_ is the desired end state. If your connection shows _Active_ but you cannot connect to the database, double-check that routes and DNS are configured correctly as those steps are outside the raw peering status.

## Troubleshooting

Use the following checks based on where the peering or connectivity process stopped.

### If a failure occurs during provisioning

If the VPC peering connection fails to provision or shows a _Failed_ status, verify the following:

-   You entered the account ID for your VPC (Accepter) correctly.
-   You have selected the correct ID for your VPC (Accepter).
-   You entered the correct region for your VPC (Accepter).
-   None of the primary or secondary CIDR blocks in your VPC overlap the cluster CIDR block or the internal services CIDR `10.129.0.0/24`.

If any of these values are incorrect, delete the failed peering request and create a new one with the correct values.

### If provisioning succeeded but you cannot connect

If the VPC peering status is _Active_, but you cannot connect to the database, check the following:

-   Routing: Your subnet uses the correct route table, with a route to the cluster CIDR block pointing to the peering connection. Confirm that route entries exist in the route tables attached to your application subnets.
-   DNS: DNS resolution returns Aerospike private IPs. Verify that the hosted zone association completed successfully, and that `enableDnsSupport` and `enableDnsHostnames` are set to `true` in your VPC settings. These settings appear as _DNS hostnames_ and _DNS resolution_ in the VPC Console UI.
-   Ports: Client and AQL tests use TLS port `4000`.
-   Security groups: Your security groups allow outbound TCP `4000` to the cluster CIDR block. See [AWS Security Group Rules documentation](https://docs.aws.amazon.com/vpc/latest/userguide/security-group-rules.html) for more details.
-   Network ACLs: No network ACLs are blocking the traffic.
-   Propagation time: You waited at least 10 minutes after applying route changes for them to propagate.

The [AWS Network Reachability Analyzer tool](https://docs.aws.amazon.com/vpc/latest/reachability/getting-started.html) is helpful for debugging network connectivity issues.

::: tip
If writes fail with `FAIL_FORBIDDEN`, the issue may be unrelated to connectivity or permissions. See [FAIL\_FORBIDDEN on writes](https://aerospike.com/docs/cloud/develop/client/#fail_forbidden-on-writes) for details.
:::

## Conclusion

After peering is active and routes are properly configured, your AWS resources (EC2, EKS, and similar compute services) communicate privately with Aerospike Cloud. This approach eliminates internet exposure and generally yields lower latency.

If you experience any issues connecting, see the [Troubleshooting](#troubleshooting) section.

## What’s next

After VPC peering is configured, create database users and connect your applications:

-   [Create your first database user](https://aerospike.com/docs/cloud/manage/database-users)
-   [Configure Aerospike clients](https://aerospike.com/docs/cloud/develop/client) for application connectivity