---
title: VPC peering
description: Learn how to configure VPC peering to connect Databricks clusters to other parts of your AWS infrastructure using private IP addresses within the internal AWS network.
canonical_url: https://docs.databricks.com/aws/en/security/network/classic/vpc-peering
---

# VPC peering

VPC peering allows your Databricks clusters to connect to your other AWS infrastructure (RDS, Redshift, Kafka, Cassandra, and so on) using private IP addresses within the internal AWS network.

The VPC hosting the other infrastructure must have a CIDR range distinct from the Databricks VPC and any other CIDR range included as a destination in the Databricks VPC main route table. If you have a conflict, you can contact Databricks support to inquire about moving your Databricks VPC to a new CIDR range of your choice. You can view this by searching for the Databricks VPC in your AWS Console, clicking on the main route table associated with it, and then examining the **Route Tables** tab. Here is an example of a main route table for a Databricks deployment that is already peered with several other VPCs:

![Databricks VPC Route Table](https://docs.databricks.com/aws/en/images/vpc-peer/dbc-vpc-route-table.png)

For information on VPC peering, see the [AWS VPC Peering guide](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-peering.html).

This guide walks you through an example of peering an AWS Aurora RDS to your Databricks VPC using the AWS Console. If you prefer a programmatic solution, go to [Programmatic VPC peering](https://docs.databricks.com/aws/en/security/network/classic/vpc-peering.md#programmatic-peering) for a notebook that performs all of the steps for you. Finally, there is a [troubleshooting](https://docs.databricks.com/aws/en/security/network/classic/vpc-peering.md#troubleshooting) section for common problems and resolutions.

> [!IMPORTANT]
>
> Consult your AWS/devops team before trying to set up VPC peering. Some familiarity with AWS as well as sufficient permissions will ensure this process goes smoothly. The notebook can help you make this transition, however depending on your environment it is important to ensure to make the necessary modifications to ensure there is no impact to your existing infrastructure.

## AWS Console example

The following diagram illustrates all of the different components that are involved in peering your Databricks deployment to your other AWS infrastructure. In the example, Databricks is deployed in one AWS account and the Aurora RDS is deployed into another. A peering connection is established to link the two VPCs across both AWS accounts.

![VPC Peering Connection Across AWS Accounts](https://docs.databricks.com/aws/en/images/vpc-peer/aws-vpc-peer-diagram.png)

As you move through this process within your own AWS Console, it helps to keep a table of information to refer back to. Record the following:

1. ID and CIDR Range of your Databricks VPC.
2. ID and CIDR Range of your other infrastructure (Aurora RDS).
3. ID of the main route table of your Databricks VPC.

| AWS Service | Name                        | ID           | CIDR Range    |
| ----------- | --------------------------- | ------------ | ------------- |
| VPC         | Databricks VPC              | vpc-dbcb3fbc | 10.126.0.0/16 |
| VPC         | Aurora RDS VPC              | vpc-7b52471c | 172.78.0.0/16 |
| Route Table | Databricks Main Route Table | rtb-3775c750 |               |

### Create a peering connection

1. Navigate to the **VPC Dashboard**.
2. Select **Peering Connections**.
3. Click **Create Peering Connection**
4. Set the **VPC Requester** to the Databricks VPC ID.
5. Set the **VPC Acceptor** to the Aurora VPC ID.
6. Click **Create Peering Connection**.

   ![Create Peering Connection](https://docs.databricks.com/aws/en/images/vpc-peer/aws-peering-connection.png)

### Record the ID of the peering connection

| AWS Service        | Name                          | ID           | CIDR Range    |
| ------------------ | ----------------------------- | ------------ | ------------- |
| VPC                | Databricks VPC                | vpc-dbcb3fbc | 10.126.0.0/16 |
| VPC                | Aurora RDS VPC                | vpc-7b52471c | 172.78.0.0/16 |
| Route Table        | Databricks Main Route Table   | rtb-3775c750 |               |
| Peering Connection | Databricks VPC \<> Aurora VPC | pcx-4d148024 |               |

### Accept the peering connection request

The VPC with the Aurora RDS will need to have its owner approve the request. The status on Peering Connections indicates **Pending Acceptance** until this is done.

![Peering Connection Pending Acceptance](https://docs.databricks.com/aws/en/images/vpc-peer/aws-vpc-peering-connection-pending.png)

Select **Actions > Accept Request**.

![Peering Connection Accept Request](https://docs.databricks.com/aws/en/images/vpc-peer/aws-vpc-peering-connection-accept.png)

### Add DNS resolution to peering connection

1. Log into the AWS Account that hosts the Databricks VPC.
2. Navigate to the **VPC Dashboard**.
3. Select **Peering Connections**.
4. From the Actions menu, select **Edit DNS Settings**.
5. Click to enable **DNS resolution**.
6. Log into the AWS Account that hosts the Aurora VPC and repeat sub-steps 2–4.

![Enable DNS Resolution](https://docs.databricks.com/aws/en/images/vpc-peer/aws-vpc-peering-connection-enable-dns.png)

### Add destination to Databricks VPC main route table

1. Select **Route Tables** in the VPC Dashboard.
2. Search for the Databricks VPC ID.
3. Click the **Edit** button under the **Routes** tab.
4. Click **Add another route**.
5. Enter the CIDR range of the Aurora VPC for the **Destination**.
6. Enter the ID of the peering connection for the **Target**.

   ![Databricks VPC Route Destinations](https://docs.databricks.com/aws/en/images/vpc-peer/dbc-vpc-route-table-route.png)

### Add destination to Aurora VPC main route table

1. Select **Route Tables** in the VPC Dashboard.
2. Search for the Aurora VPC ID.
3. Click the **Edit** button under the **Routes** tab.
4. Click **Add another route**.
5. Enter the CIDR range of the Databricks VPC for the **Destination**.
6. Enter the ID of the peering connection for the **Target**.

   ![Aurora VPC Route Destinations](https://docs.databricks.com/aws/en/images/vpc-peer/aurora-vpc-route-table-route.png)

### Find the Databricks worker security group

1. Select **Security Groups** in the VPC Dashboard.
2. Search for the ID of the Databricks VPC.
3. If you're using a Databricks managed VPC, find and record the ID of the security group associated with Databricks worker nodes. Older workspaces might label this group **Unmanaged**, although newer workspaces might use a different name such as **no-ingress** or **workers**. Look for the security group that is *not* labeled **Managed**. If you see more than one non-managed group, select the one used by your Databricks cluster worker nodes.
4. If you're using a customer-managed VPC, any security group registered in your [customer-managed VPC](https://docs.databricks.com/aws/en/security/network/classic/customer-managed-vpc.md) will work.

| AWS Service        | Name                          | ID           | CIDR Range    |
| ------------------ | ----------------------------- | ------------ | ------------- |
| VPC                | Databricks VPC                | vpc-dbcb3fbc | 10.126.0.0/16 |
| VPC                | Aurora RDS VPC                | vpc-7b52471c | 172.78.0.0/16 |
| Route Table        | Databricks Main Route Table   | rtb-3775c750 |               |
| Peering Connection | Databricks VPC \<> Aurora VPC | pcx-4d148024 |               |
| Security Group     | Databricks Worker Group       | sg-96016bef  |               |

### Add rule to the Aurora security group

1. Select **Security Groups** in the VPC Dashboard.
2. Search for the ID of the Aurora VPC.
3. Add an **Inbound Rule** by clicking **Edit** and then **Add Another Rule**.
4. Select **Custom TCP Rule** or the service that relates to your RDS.
5. Set the **Port Range** to correspond to your RDS service. The default for Aurora \[MySQL] is 3306.
6. Set the **Source** to be the security group ID of the Databricks worker security group you recorded when finding the worker security group.

   ![Aurora Security Group Rule](https://docs.databricks.com/aws/en/images/vpc-peer/aurora-security-group-rule.png)

### Test connectivity

1. Create a Databricks cluster.
2. In a notebook cell, check to see if you can connect to the database with the following `netcat` command:

   ```bash
   %sh nc -zv <hostname> <port>
   ```

   ![Validate Connectivity](https://docs.databricks.com/aws/en/images/vpc-peer/aws-vpc-peering-validate.png)

## <a id="programmatic-peering" />Programmatic VPC peering

This notebook supports two scenarios:

* Establishing VPC peering between Databricks VPC and another VPC in the same AWS account
* Establishing VPC peering between Databricks VPC and another VPC in a different AWS account

#### VPC peering notebook

[Get notebook](https://docs.databricks.com/notebooks/source/vpc-peering.html)

## <a id="troubleshooting" />Troubleshooting

**Can't establish connectivity with `netcat`**

If you can't establish connectivity with `netcat`, check that the hostname is resolving via DNS by using the `host` Linux command. If the hostname does not resolve, verify that you have enabled DNS resolution in your peering connection.

```bash
%sh host -t a <hostname>
```

![Validate DNS Resolution](https://docs.databricks.com/aws/en/images/vpc-peer/aws-validate-dns.png)

**Can't establish connectivity with the hostname or the IP address**

If you aren't able to establish connectivity with either the hostname or the IP address, verify that the VPC of your Aurora RDS has 3 subnets associated with its main route table.

1. Select **Subnets** from the **VPC Dashboard** and search for the ID of the Aurora VPC. There should be a subnet for each availability zone.

   ![Aurora VPC Subnets](https://docs.databricks.com/aws/en/images/vpc-peer/aws-vpc-aurora-subnets.png)

2. Make sure that each of those subnets uses the main route table through implicit association, not an explicit subnet association.
   1. Select **Route Tables** from the VPC Dashboard and search for the main route table associated with the Aurora RDS.
   2. Click the **Subnet Associations** tab and then **Edit**. You should see all 3 subnets in the list, but none of them should have **Associate** selected.

      ![Aurora Subnet Associations](https://docs.databricks.com/aws/en/images/vpc-peer/aurora-subnet-associations.png)

**DNS is not working**

Check in Route 53 and confirm that the Databricks VPC is associated with the private hosted zones used within your VPC.
