To prevent denial-of-service and brute force password attacks, CockroachCloud requires you to authorize networks that can access your cluster by allowlisting the public IP addresses for your application. Optionally, you can set up Virtual Private Cloud (VPC) peering or AWS PrivateLink for your cluster for enhanced network security and lower network latency.
IP allowlisting
Authorize your application server’s network and your local machine’s network by adding their public IP addresses (in the CIDR format) to the CockroachCloud cluster's allowlist. If you change your location, you will need to authorize the new location’s network, else the connection from that network will be rejected.
- In a development environment, you need to authorize your application server’s network and your local machine’s network. If you change your location, you need to authorize the new location’s network, or else the connection from that network will be rejected.
- In a production environment, you need to authorize your application server’s network.
While developing and testing your application, you may add 0.0.0.0/0
to the allowlist, which allows all networks. However, before moving into production, make sure you delete the 0.0.0.0/0
network.
If your application servers’ IP addresses are not static or you want to limit your cluster's exposure to the public network, you can connect to your CockroachCloud clusters using VPC Peering or AWS PrivateLink instead.
VPC peering
If you select GCP as your cloud provider while creating your CockroachCloud cluster, you can use Google Cloud's VPC Network Peering feature to connect your GCP application directly to your CockroachCloud cluster using internal IP addresses, thus limiting exposure to the public network and reducing network latency.
Setting up a VPC peering connection between your CockroachCloud cluster and GCP application is a two-part process:
- Configure the IP range and size while creating the CockroachCloud cluster
- Configure a peering connection after creating the cluster
Self-service VPC peering setup is available only while creating a new CockroachCloud cluster. To set up VPC peering for existing clusters, contact us.
Configure the IP range and size while creating your CockroachCloud cluster
While creating your CockroachCloud cluster, enable VPC peering and configure the IP address range and size (in CIDR format) for the CockroachCloud network based on the following considerations:
- To adhere to GCP's overlapping subnets restriction, configure an IP range that doesn't overlap with the IP ranges in your application network.
- The IP range and size cannot be changed after the cluster is created. Configuring a smaller IP range size may limit your ability to expand into multiple regions in the future. We recommend configuring an IP range size of
/16
or lower.
Alternatively, you can use CockroachCloud's default IP range and size (172.28.0.0/14
) as long as it doesn't overlap with the IP ranges in your network.
Establish a VPC Peering connection after creating your CockroachCloud cluster
After creating your CockroachCloud cluster, request a peering connection from CockroachCloud's Networking page. Then accept the request by running the gcloud
command displayed your screen. You can check the status of the connection on the Peering tab on the Networking page. The status is shown as PENDING
until you accept the connection request from the GCP side. After the connection is successfully established, the status changes to ACTIVE
. You can then select a connection method and connect to your cluster.
AWS PrivateLink
If your cloud provider is AWS, you can use AWS PrivateLink to securely connect your AWS application with your CockroachCloud cluster using a private endpoint. Like VPC Peering, a PrivateLink connection will prevent your traffic from being exposed to the public internet and reduce network latency.
There are four steps to setting up an AWS PrivateLink connection between your CockroachCloud cluster and AWS application:
Set up a cluster
Use the CockroachCloud Console to create your CockroachCloud cluster on AWS in the same region as your application.
Note:If you have a multi-region cluster, you will have to create a PrivateLink connection for each region you are operating in.
Navigate to the Networking page.
Select the PrivateLink tab.
Click Set up a PrivateLink connection to open the connection modal.
Create an AWS endpoint
- If you have a multi-region cluster, select the region to create a connection in. Skip this step if you have a single-region cluster.
- Copy the Service Name shown in the connection modal.
- On the Amazon VPC Console, click Your VPCs in the sidebar.
Locate the VPC ID of the VPC you want to create your endpoint in.
This will probably be the same VPC as the VPC your EC2 instances and application are running in. You can also choose a different VPC as long as it is peered to the VPC your application is running in.
On the Your VPCs page, locate the IPv4 CIDR corresponding to the VPC you chose in Step 3.
Click Subnets in the sidebar.
Locate the subnet IDs corresponding to the VPC you chose in Step 3.
Click Security Groups in the sidebar.
Click Create security group to create a security group within your VPC that allows inbound access from your EC2 instances on Port 26257:
- In the Security group name field, enter a name for the security group.
- In the Description field, enter a description for the security group.
- From the VPC dropdown, select the VPC you chose in Step 3.
- In the Inbound rules section, click Add rule. Enter 26257 in the Port range field. In the Source field, enter the CIDR range from Step 4.
- Click Create security group.
Use either the Amazon VPC Console or the AWS Command Line Interface (CLI) to continue:
- Click Endpoints in the sidebar.
- Click Create Endpoint.
- On the Create Endpoint page, for the Service Category field, select Find service by name.
- In the Service Name field, enter the Service Name copied from the connection modal in Step 1.
- Click Verify.
- In the VPC field, enter the ID of the VPC you want to create your endpoint in.
- Verify that the subnets are pre-populated.
- In the Security group section, select the security group you created in Step 8 and uncheck the box for default security group.
Click Create Endpoint.
The VPC Endpoint ID displays.
Copy the Endpoint ID to your clipboard and return to CockroachCloud's Add PrivateLink modal.
Substitute the values from the previous steps and run the following AWS CLI command:
$ aws ec2 create-vpc-endpoint --region $REGION \ --vpc-id $VPC_ID --subnet-ids $SUBNET_ID1 $SUBNET_ID2 \ --vpc-endpoint-type Interface --security-group-ids \ $SECURITY_GROUP_ID1 $SECURITY_GROUP_ID2 --service-name \ $SERVICE_NAME_PROVIDED_BY_COCKROACH
Locate the VPC Endpoint ID in the CLI output.
Copy the Endpoint ID to your clipboard and return to CockroachCloud's Add PrivateLink modal.
Verify the endpoint ID
- Paste the Endpoint ID you created into the VPC Endpoint ID field.
- Click Verify.
- CockroachCloud will accept the endpoint request. You can confirm the request acceptance by checking if the status is listed as Available on the Amazon VPC Console Endpoints page.
Enable private DNS
- On the Amazon VPC Console Endpoints page, select the endpoint you created.
- Click Actions.
- Click Modify Private DNS Names.
- Check the Enable Private DNS Name checkbox.
- Click Modify Private DNS Name.
Alternatively, use the AWS CLI to modify the Private DNS Name:
After the endpoint status changes to Available, run the following AWS CLI command:
$ aws ec2 modify-vpc-endpoint --region $REGION \ --private-dns-enabled --vpc-endpoint-id $VPC_ENDPOINT_ID
The endpoint status will change to Pending.
After a short (less than 5 minute) delay, the status will change to Available. You can now connect to your cluster.