Export the bootstrap broker addresses for your MSK cluster’s IAM listener:
export MSK_BOOTSTRAP_SERVERS="b-1.example.abc123.c2.kafka.us-east-1.amazonaws.com:9098,b-2.example.abc123.c2.kafka.us-east-1.amazonaws.com:9098,b-3.example.abc123.c2.kafka.us-east-1.amazonaws.com:9098"
Build the request body for a backend cluster using sasl_aws_iam authentication with the default AWS credentials provider chain:
jq -n --arg brokers "$MSK_BOOTSTRAP_SERVERS" \
'{
"name": "msk_backend_cluster",
"bootstrap_servers": ($brokers | split(",")),
"authentication": {
"type": "sasl_aws_iam",
"sasl_aws_iam": {"type": "default_provider_chain"}
},
"insecure_allow_anonymous_virtual_cluster_auth": true,
"tls": {"enabled": true}
}' > msk_backend_cluster.json
Then, create the backend cluster:
MSK_BACKEND_CLUSTER_ID=$(curl -X POST "https://us.api.konghq.com/v1/event-gateways/$EVENT_GATEWAY_ID/backend-clusters" \
--no-progress-meter --fail-with-body \
-H "Authorization: Bearer $KONNECT_TOKEN" \
--json "$(cat msk_backend_cluster.json)" | jq -r ".id"
)
default_provider_chain tells Event Gateway to resolve AWS credentials the same way the AWS CLI and SDKs do.
If you need Event Gateway to assume a role before connecting, for example to access an MSK cluster in another AWS account, use sasl_aws_iam.type: assume_role instead:
{
"authentication": {
"type": "sasl_aws_iam",
"sasl_aws_iam": {
"type": "assume_role",
"assume_role": {
"arn": "arn:aws:iam::123456789012:role/example-role",
"session_name": "event-gateway-session"
}
}
}
}
Event Gateway first resolves base credentials from the default provider chain, then uses them to assume the role at arn. The role’s trust policy must allow the base credentials to assume it. session_name is optional and becomes part of the assumed role session’s ARN.