Configure AWS PrivateLink with the Cloud API

To unlock this feature for your account, contact Redpanda support.

This guide is for configuring AWS PrivateLink using the Redpanda Cloud API. See Configure PrivateLink in the Cloud UI if you want to set up the endpoint service using the UI.

The Redpanda AWS PrivateLink endpoint service provides secure access to Redpanda Cloud from your own VPC. Traffic over PrivateLink does not go through the public internet because a PrivateLink connection is treated as its own private AWS service. While your VPC has access to the Redpanda VPC, Redpanda cannot access your VPC.

Consider using the PrivateLink endpoint service if you have multiple VPCs and could benefit from a more simplified approach to network management:

  • PrivateLink allows overlapping CIDR ranges in VPC networks.

  • PrivateLink does not limit the number of VPC connections. However, VPC peering is limited to 125 connections. See How scalable is AWS PrivateLink?

Make sure to replace the variable values in the code examples on this page with your own values, before running the commands in the terminal or in a script.


  • Install rpk.

  • Your Redpanda cluster and VPC must be in the same region.

  • In this guide, you use the Redpanda Cloud API to enable the Redpanda endpoint service for your clusters. Follow the steps below to get an access token.

  • Use the AWS CLI to create a new client VPC or modify an existing one to use the PrivateLink endpoint.

Get a Cloud API access token

  1. Specify the base URL of the Redpanda Cloud API:

  2. In the Redpanda Cloud UI, go to Resource groups and select the resource group in which you want to create a cluster.

    Copy and store the resource group ID (UUID) from the URL in the browser.

  3. Go to the organization (org) level Home in the UI, and navigate to Clients. If you don’t have an existing client, you can create a new one by clicking Add client.

    Copy and store the client ID and secret.

  4. Get an API token using the client ID and secret. You can click the Request an API token link to see code examples to generate the token.

    AUTH_TOKEN=`curl -s --request POST \
        --url '' \
        --header 'content-type: application/x-www-form-urlencoded' \
        --data grant_type=client_credentials \
        --data client_id=$CLOUD_CLIENT_ID \
        --data client_secret=$CLOUD_CLIENT_SECRET \
        --data | jq .access_token | sed 's/"//g'`

You must send the API token in the Authorization header when making requests to the Cloud API.

  1. Call POST /v1beta2/networks to create a network.

    Make sure to supply your own values in the example request below. Store the network ID (network_id) after the network is created in order to check whether you can proceed to cluster creation.

    • name

    • cidr_block

    • aws_region

        "cloud_provider": "CLOUD_PROVIDER_AWS",
        "cluster_type": "TYPE_BYOC",
        "name": "<my-private-link-network>",
        "cidr_block": "<>",
        "resource_group_id": "$RESOURCE_GROUP_ID",
        "region": "$REGION"
    NETWORK_ID=`curl -vv -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer $AUTH_TOKEN" \
        -d "$NETWORK_POST_BODY" $PUBLIC_API_ENDPOINT/v1beta2/networks | jq .metadata.network_id`
    echo $NETWORK_ID

    Wait for the network to be ready before creating the cluster in the next step. You can check the state of the network creation by calling GET /v1beta2/networks/{id}. You can create the cluster when the state is STATE_READY.

  2. Create a new cluster with the endpoint service enabled by calling POST /v1beta2/clusters.

    In the example below, make sure to set your own values for the following fields:

    • zones: for example, "usw2-az1","usw2-az2","usw2-az3"

    • type: TYPE_DEDICATED for Dedicated Cloud clusters, or TYPE_BYOC for BYOC clusters

    • tier: for example, tier-1-aws-v2-arm

    • name

    • allowed_principals: Amazon Resource Names (ARNs) for the AWS principals allowed to access the endpoint service. For example, for all principals in an account, use arn:aws:iam::account_id:root. See Configure an endpoint service for details.

        "cloud_provider": "CLOUD_PROVIDER_AWS",
        "connection_type": "CONNECTION_TYPE_PRIVATE",
        "name": "<my-private-link-cluster>",
        "resource_group_id": "$RESOURCE_GROUP_ID",
        "network_id": "$NETWORK_ID",
        "region": "$REGION",
        "zones": [ <zones> ],
        "throughput_tier": "<tier>",
        "type": "<type>",
        "aws_private_link": {
            "enabled": true,
            "allowed_principals": ["<principal_1>","<principal_2>"]
    CLUSTER_ID=`curl -vv -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer $AUTH_TOKEN" \
        -d "$CLUSTER_POST_BODY" $PUBLIC_API_ENDPOINT/v1beta2/clusters | jq .operation.metadata.cluster_id | sed 's/"//g'`
    echo $CLUSTER_ID

    BYOC clusters: Check that the cluster operation is completed by calling GET /v1beta2/operations/{id}, and passing the operation ID returned from the Create Cluster call.

    When the Create Cluster operation is completed (STATE_COMPLETED), run the following rpk cloud command to finish setting up your BYOC cluster:

    rpk cloud byoc aws apply --redpanda-id=$CLUSTER_ID
  1. In the Redpanda Cloud UI, go to the cluster overview and copy the cluster ID from the Details section.

  2. Make a PATCH /v1beta2/clusters/{} request to update the cluster with the Redpanda Private Link Endpoint Service enabled.

    In the example below, make sure to set your own value for the following field:

    • allowed_principals: Amazon Resource Names (ARNs) for the AWS principals allowed to access the endpoint service. For example, for all principals in an account, use arn:aws:iam::account_id:root. See Configure an endpoint service for details.

      "aws_private_link": {
        "enabled": true,
        "allowed_principals": ["<principal_1>","<principal_2>"]
    curl -vv -X PATCH \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $AUTH_TOKEN" \
  3. Before proceeding, check the state of the Update Cluster operation by calling GET /v1beta2/operations/{id}, and passing the operation ID returned from Update Cluster call. When the state is STATE_READY, proceed to the next step.

  4. Check the service state by calling GET /v1beta2/clusters/{id}. The service_state in the aws_private_link.status response object must be Available for you to connect to the service.

    curl -X GET \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer $AUTH_TOKEN" \
        $PUBLIC_API_ENDPOINT/v1beta2/clusters/$CLUSTER_ID | jq '.cluster.aws_private_link.status | {service_name, service_state}'

When you have a PrivateLink-enabled cluster, you can create an endpoint to connect your VPC and your cluster.

Get cluster domain

Get the domain (cluster_domain) of the cluster from the cluster details in the Redpanda Cloud UI.

For example, if the bootstrap server URL is:, then cluster_domain is:


The service name is required to create VPC private endpoints. Run the following command to get the service name:

  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AUTH_TOKEN" \
  $PUBLIC_API_ENDPOINT/v1beta2/clusters/$CLUSTER_ID | jq -r .cluster.aws_private_link.status.service_name`

Create client VPC

If you are not using an existing VPC, you must create a new one.

VPC peering and PrivateLink will not work at the same time if you set them up on the same VPC where your Kafka clients run. PrivateLink endpoints take priority.

VPC peering and PrivateLink can both be used at the same time if Kafka clients are connecting from distinct VPCs. For example, in a private Redpanda cluster, you can connect your internal Kafka clients over VPC peering, and enable PrivateLink for external services.

The VPC region must be the same region where the Redpanda cluster is deployed. Run the following command to create the VPC:

# See for
# information on profiles and credential files

aws ec2 create-vpc --region $REGION --profile $PROFILE --cidr-block

# Store the client VPC ID from the command output

You can also use an existing VPC. You need the VPC ID to modify its DNS attributes.

Modify VPC DNS attributes

Modify the VPC attributes using the following commands:

aws ec2 modify-vpc-attribute --region $REGION --profile $PROFILE --vpc-id $CLIENT_VPC_ID \
    --enable-dns-hostnames "{\"Value\":true}"

aws ec2 modify-vpc-attribute --region $REGION --profile $PROFILE --vpc-id $CLIENT_VPC_ID \
    --enable-dns-support "{\"Value\":true}"

These commands enable DNS hostnames and resolution for instances in the VPC.

Create security group

You need the security group ID security_group_id from the command output to add security group rules. Run the following command to create a security group:

aws ec2 create-security-group --region $REGION --profile $PROFILE --vpc-id $CLIENT_VPC_ID \
    --description "Redpanda endpoint service client security group" \
    --group-name "${CLUSTER_ID}-sg"

Add security group rules

The example below to add security group rules is based on the assumption that the Redpanda broker count is three. If you are not using three brokers, modify the example:

  • Replace 32094 with 32092 + <broker_count-1>.

  • Replace 35084 with 35082 + <broker_count-1>.

aws ec2 authorize-security-group-ingress --region $REGION --profile $PROFILE \
    --group-id $SECURITY_GROUP_ID \
    --protocol "tcp" \
    --port 30292 \
aws ec2 authorize-security-group-ingress --region $REGION --profile $PROFILE \
    --group-id $SECURITY_GROUP_ID --protocol "tcp" \
    --port 30081 \
aws ec2 authorize-security-group-ingress --region $REGION --profile $PROFILE \
    --group-id $SECURITY_GROUP_ID --protocol "tcp" \
    --port 30282 \
# Adjust the port 32094 if the Redpanda broker count is not 3.
aws ec2 authorize-security-group-ingress --region $REGION --profile $PROFILE \
    --group-id $SECURITY_GROUP_ID \
    --protocol "tcp" \
    --port 32092-32094 \
# Adjust the port 35084 if the Redpanda broker count is not 3.
aws ec2 authorize-security-group-ingress --region $REGION --profile $PROFILE \
    --group-id $SECURITY_GROUP_ID \
    --protocol "tcp" \
    --port 35082-35084 \

Create VPC subnet

You need the subnet ID subnet_id from the command output to create a VPC endpoint. Run the following command, specifying the subnet availability zone (for example, usw2-az1):

aws ec2 create-subnet --region $REGION --profile $PROFILE --vpc-id $CLIENT_VPC_ID \
    --availability-zone <zone> \

Create VPC endpoint

aws ec2 create-vpc-endpoint \
    --region $REGION --profile $PROFILE \
    --vpc-id $CLIENT_VPC_ID \
    --vpc-endpoint-type "Interface" \
    --ip-address-type "ipv4" \
    --service-name $PL_SERVICE_NAME \
    --subnet-ids $SUBNET_ID \
    --security-group-ids $SECURITY_GROUP_ID \

Access Redpanda services through VPC endpoint

After you have enabled PrivateLink for your cluster, your connection URLs are available in the How to Connect section of the cluster overview in the Redpanda Cloud UI.

You can access Redpanda services such as Schema Registry and HTTP Proxy from the client VPC, for example, from a compute instance in the VPC.

The bootstrap server hostname is unique to each cluster. The service attachment exposes a set of bootstrap ports for access to Redpanda services. These ports load balance requests among brokers. Make sure you use the following ports for initiating a connection from a consumer:

Redpanda service Default bootstrap port

Kafka API


HTTP Proxy


Schema Registry


Access Kafka API seed service

Use port 30292 to access the Kafka API seed service.

export REDPANDA_BROKERS='<kafka-api-bootstrap-server-hostname>:30292'
rpk cluster info -X tls.enabled=true -X user=<user> -X pass=<password>

When successful, the rpk output should look like the following:


ID    HOST                                                                PORT   RACK
0*  32092  use2-az1
1  32093  use2-az1
2  32094  use2-az1

Access Schema Registry seed service

Use port 30081 to access the Schema Registry seed service.

curl -vv -u <username>:<password> -H "Content-Type: application/vnd.schemaregistry.v1+json" --sslv2 --http2 <schema-registry-bootstrap-server-hostname>:30081/subjects

Access HTTP Proxy seed service

Use port 30282 to access the Redpanda HTTP Proxy seed service.

curl -vv -u <username>:<password> -H "Content-Type: application/vnd.kafka.json.v2+json" --sslv2 --http2 <http-proxy-bootstrap-server-hostname>:30282/topics

Test the connection

You can test the PrivateLink connection from any VM or container in the consumer VPC. If configuring a client isn’t possible right away, you can do these checks using rpk or cURL:

  1. Set the following environment variables.

    export REDPANDA_BROKERS='<kafka-api-bootstrap-server-hostname>:30292'
    export RPK_TLS_ENABLED=true
    export RPK_USER=<user>
    export RPK_PASS=<password>
  2. Create a test topic.

    rpk topic create test-topic
  3. Produce to the test topic.

    • rpk

    • curl

    echo 'hello world' | rpk topic produce test-topic
    curl -s \
      -X POST \
      "<http-proxy-bootstrap-server-url>/topics/test-topic" \
      -H "Content-Type: application/vnd.kafka.json.v2+json" \
      -d '{
              "value":"hello world"
  4. Consume from the test topic.

    • rpk

    • curl

    rpk topic consume test-topic -n 1
    curl -s \
      -H "Accept: application/vnd.kafka.json.v2+json"