Use Amazon MSK APIs with Interface VPC Endpoints - Amazon Managed Streaming for Apache Kafka
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use Amazon MSK APIs with Interface VPC Endpoints

You can use an Interface VPC Endpoint, powered by Amazon PrivateLink, to prevent traffic between your Amazon VPC and Amazon MSK APIs from leaving the Amazon network. Interface VPC Endpoints don't require an internet gateway, NAT device, VPN connection, or Amazon Direct Connect connection. Amazon PrivateLink is an Amazon technology that enables private communication between Amazon services using an elastic network interface with private IPs in your Amazon VPC. For more information, see Amazon Virtual Private Cloud and Interface VPC Endpoints (Amazon PrivateLink).

Your applications can connect with Amazon MSK Provisioned and MSK Connect APIs using Amazon PrivateLink. To get started, create an Interface VPC Endpoint for your Amazon MSK API to start traffic flowing from and to your Amazon VPC resources through the Interface VPC Endpoint. FIPS-enabled Interface VPC endpoints are available for US Regions. For more information, see Create an Interface Endpoint.

Using this feature, your Apache Kafka clients can dynamically fetch the connection strings to connect with MSK Provisioned or MSK Connect resources without traversing the internet to retrieve the connection strings.

When creating an Interface VPC Endpoint, choose one of the following service name endpoints:

For MSK Provisioned:
  • com.amazonaws.region.kafka

  • com.amazonaws.region.kafka-fips (FIPS-enabled)

Where region is your region name. Choose this service name to work with MSK Provisioned-compatible APIs. For more information, see Operations in the https://docs.amazonaws.cn/msk/1.0/apireference/.

For MSK Connect:
  • com.amazonaws.region.kafkaconnect

Where region is your region name. Choose this service name to work with MSK Connect-compatible APIs. For more information, see Actions in the Amazon MSK Connect API Reference.

For more information, including step-by-step instructions to create an interface VPC endpoint, see Creating an interface endpoint in the Amazon PrivateLink Guide.

Control access to VPC endpoints for Amazon MSK Provisioned or MSK Connect APIs

VPC endpoint policies let you control access by either attaching a policy to a VPC endpoint or by using additional fields in a policy that is attached to an IAM user, group, or role to restrict access to occur only through the specified VPC endpoint. Use the appropriate example policy to define access permissions for either MSK Provisioned or MSK Connect service.

If you don't attach a policy when you create an endpoint, Amazon VPC attaches a default policy for you that allows full access to the service. An endpoint policy doesn't override or replace IAM identity-based policies or service-specific policies. It's a separate policy for controlling access from the endpoint to the specified service.

For more information, see Controlling Access to Services with VPC Endpoints in the Amazon PrivateLink Guide.

MSK Provisioned — VPC policy example
Read-only access

This sample policy can be attached to a VPC endpoint. (For more information, see Controlling Access to Amazon VPC Resources). It restricts actions to only listing and describing operations through the VPC endpoint to which it is attached.

{ "Statement": [ { "Sid": "MSKReadOnly", "Principal": "*", "Action": [ "kafka:List*", "kafka:Describe*" ], "Effect": "Allow", "Resource": "*" } ] }
MSK Provisioned — VPC endpoint policy example

Restrict access to a specific MSK cluster

This sample policy can be attached to a VPC endpoint. It restricts access to a specific Kafka cluster through the VPC endpoint to which it is attached.

{ "Statement": [ { "Sid": "AccessToSpecificCluster", "Principal": "*", "Action": "kafka:*", "Effect": "Allow", "Resource": "arn:aws:kafka:us-east-1:123456789012:cluster/MyCluster" } ] }
MSK Connect — VPC endpoint policy example
List connectors and create a new connector

The following is an example of an endpoint policy for MSK Connect. This policy allows the specified role to list connectors and create a new connector.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "MSKConnectPermissions", "Effect": "Allow", "Action": [ "kafkaconnect:ListConnectors", "kafkaconnect:CreateConnector" ], "Resource": "*", "Principal": { "AWS": [ "arn:aws:iam::111122223333:role/<ExampleRole>" ] } } ] }
MSK Connect — VPC endpoint policy example

Allows only requests from a specific IP address in the specified VPC

The following example shows a policy that only allows requests coming from a specified IP address in the specified VPC to succeed. Requests from other IP addresses will fail.

{ "Statement": [ { "Action": "kafkaconnect:*", "Effect": "Allow", "Principal": "*", "Resource": "*", "Condition": { "IpAddress": { "aws:VpcSourceIp": "192.0.2.123" }, "StringEquals": { "aws:SourceVpc": "vpc-555555555555" } } } ] }