- Newest
- Most votes
- Most comments
Greeting
Hi Jove,
Thanks for sharing your detailed setup and challenges. I understand how frustrating it can be to troubleshoot complex multi-VPC connectivity issues, especially when working across AWS accounts with IAM and private networking. Let’s dive deeper and resolve this together. 😊
Clarifying the Issue
From your description, you’re setting up multi-VPC private connectivity for an Amazon MSK cluster in Account A, accessed securely from an EC2 instance in Account B using IAM-based authentication. While you’ve followed the AWS blog and documentation, you’re unable to list topics in the MSK cluster, facing a SASL_AUTHENTICATION_FAILED error.
Key pain points:
- IAM Policy Confusion: Uncertainty around which ARN to use for IAM permissions in Account B.
- Security Group Rules: Questions about configuring the VPC endpoint security group correctly.
- Debugging SASL Authentication: Logs indicate the client can connect but fails authentication.
This updated guide adds more details on IAM roles, network debugging, and potential edge cases to help you succeed.
Why This Matters
Successfully configuring multi-VPC private connectivity ensures your Kafka applications remain secure, scalable, and compliant with AWS best practices. This setup is critical for organizations managing cross-account workloads while maintaining secure isolation between environments.
Key Terms
- Amazon MSK: Managed Kafka service enabling scalable, secure stream processing.
- SASL Authentication: Mechanism supporting IAM-based authentication for secure communication.
- VPC Endpoint: Private connection to AWS services without public internet exposure.
- IAM Role: Cross-account access mechanism allowing secure permission delegation.
- Security Group: A virtual firewall controlling inbound and outbound traffic for AWS resources.
- DNS Resolution: Translation of domain names to IP addresses for VPC endpoints and other services.
The Solution (Our Recipe)
Steps at a Glance:
- Configure IAM roles and policies for cross-account access.
- Verify security group rules for the MSK cluster and VPC endpoint.
- Check VPC peering, route tables, and DNS resolution.
- Debug SASL authentication and validate client configuration.
- Test Connectivity.
Step-by-Step Guide:
- Set Up IAM Role in Account B
- Ensure the IAM policy in Account B grants access to the MSK cluster in Account A. Use the MSK ARN from Account A for the
Resource. - Example IAM policy:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kafka-cluster:Connect", "kafka-cluster:DescribeCluster" ], "Resource": "arn:aws:kafka:us-west-2:ACCOUNT_A_ID:cluster/demo-cluster-1/*" }, { "Effect": "Allow", "Action": [ "kafka-cluster:ReadData", "kafka-cluster:WriteData" ], "Resource": "arn:aws:kafka:us-west-2:ACCOUNT_A_ID:topic/demo-cluster-1/*" } ] } - Attach this policy to the IAM role assigned to the EC2 instance in Account B.
- Ensure the IAM policy in Account B grants access to the MSK cluster in Account A. Use the MSK ARN from Account A for the
- Configure Security Groups
- For the MSK cluster in Account A:
- Allow inbound traffic on ports
14001-14100from the security group of the VPC endpoint in Account B.
- Allow inbound traffic on ports
- For the VPC endpoint in Account B:
- Allow outbound traffic to the MSK security group in Account A.
- Example commands:
# Inbound rule for MSK security group aws ec2 authorize-security-group-ingress \ --group-id sg-MSK_GROUP_ID \ --protocol tcp \ --port 14001-14100 \ --source-group sg-ENDPOINT_GROUP_ID # Outbound rule for VPC endpoint security group aws ec2 authorize-security-group-egress \ --group-id sg-ENDPOINT_GROUP_ID \ --protocol tcp \ --port 14001-14100 \ --destination-group sg-MSK_GROUP_ID
- For the MSK cluster in Account A:
-
Verify VPC Peering and Route Tables
- Ensure VPC peering is correctly configured between Account A and Account B.
- Update route tables in both VPCs to enable traffic between subnets.
- Verify DNS resolution for the VPC endpoint is enabled:
aws ec2 modify-vpc-endpoint \ --vpc-endpoint-id vpce-12345 \ --private-dns-enabled
-
Debug SASL Authentication
- Ensure the Redpanda Console uses the correct IAM role via the instance profile.
- Validate
config.yaml:kafka: brokers: - b-1.iam.democluster1.someid.c6.kafka.us-west-2.amazonaws.com:14001 sasl: enabled: true mechanism: AWS_MSK_IAM awsMskIam: region: us-west-2 tls: enabled: true - Enable detailed logging in CloudWatch for further debugging:
- Look for
Access Deniedor misconfiguration in the IAM role.
- Look for
- Test Connectivity
- Use tools like
telnetorcurlto verify connectivity to the broker:telnet b-1.iam.democluster1.someid.c6.kafka.us-west-2.amazonaws.com 14001 - Confirm successful authentication by listing topics:
kafka-topics.sh --list --bootstrap-server b-1.iam.democluster1.someid.c6.kafka.us-west-2.amazonaws.com:14001
- Use tools like
Closing Thoughts
If the problem persists, consider the following documentation for more insights:
These resources should clarify additional configurations or edge cases. Let me know how it goes or if you'd like further assistance. 😊
Farewell
Best of luck, Jove! I hope these steps help you achieve seamless cross-account MSK connectivity. Feel free to reach out if you hit any snags. 🚀
Cheers,
Aaron 😊
answered 2 years ago
HI Jove!
It seems you're dealing with a Kafka connectivity issue between an Amazon Managed Streaming for Apache Kafka (MSK) cluster and a client in a different AWS account (Account B). Let me address your concerns step-by-step.
Is the Telnet Response Normal?
The behavior you observed when running telnet is expected. Connecting to the MSK broker via Telnet validates that the network path to the broker is functioning. However, it doesn't confirm that the Kafka protocol is working or that authentication is successful. The connection closing after the ^C interruption is standard Telnet behavior.
Security Group Configuration Across Accounts
When MSK and the client reside in different accounts but within the same default VPCs, you must ensure the security groups are correctly configured.
In Account A (where MSK resides):
- MSK Security Group: Allow inbound traffic from the security group of the client in Account B. For example:
- In the MSK security group, add an inbound rule with:
- Protocol: TCP
- Port Range:
9092(or your Kafka listener port) - Source: The security group ID of the EC2 instance in Account B.
- In the MSK security group, add an inbound rule with:
In Account B (where the client resides):
- Client Security Group: Allow outbound traffic to the MSK broker in Account A.
- Outbound rule:
- Protocol: TCP
- Port Range:
9092 - Destination: The MSK security group ID in Account A.
- Outbound rule:
Private DNS Enablement
When MSK is set to use VPC endpoints (PrivateLink), private DNS resolution ensures the broker’s hostname resolves to the corresponding VPC endpoint. Typically, MSK manages this configuration automatically. You can verify this by:
- Checking the
Enable Private DNSoption for your VPC endpoint in the console. - Confirming that DNS queries for the broker's hostname resolve to a private IP within the MSK VPC.
If private DNS isn't configured correctly, you might need to set custom DNS resolution using Route 53 or edit your local /etc/hosts file for testing.
Connection Not Accepted
If your network configuration and permissions are correct, but the Kafka connection is still not accepted, consider these points:
- Authentication: MSK supports SASL (e.g., SASL/SCRAM) or IAM authentication. Ensure your client is using the appropriate credentials or IAM roles for access.
- Broker Listener Configuration: Double-check the broker endpoints in the MSK console. Ensure your client uses the internal (private) endpoint if it's connecting from within the same VPC.
- CloudWatch Logs: Examine the error messages in the MSK broker logs for details. Common issues might include authentication failures or protocol mismatches.
Let me know if you'd like further clarification or help debugging! 😊
Cheers,
Aaron 😊
answered 2 years ago
Relevant content
asked 2 years ago

Hi Aaron, I don't mind an AI helping me, however this lengthly answer is not very helpful.
I tried the
telnet host 14001and gotIs this expected or something wrong?
For the detailed steps
Since I got the error from the MSK broker in CloudWatch Logs, I think it proved the network connection is setup. There should be no inbound or outbound connectivity issue but somehow the connection from Kafka is not accepted.
Again thanks for looking into my inquiry.
That telnet session shows the connection is working