How to connect to AWS MSK using Golang?

953 views Asked by At

I have set up an MSK Kafka Cluster with SCRAM security. The VPC allows all incoming and outgoing connections.

I'm attempting to connect to the cluster using the following steps:

mechanism, err := scram.Mechanism(scram.SHA512, "user", "user-secret")
if err != nil {
    panic(err)
}

dialer := &kafka.Dialer{
    Timeout:       100 * time.Second,
    DualStack:     true,
    SASLMechanism: mechanism,
}

conn, err := dialer.Dial("tcp", "z-2.<cluster-name>.<extra-info>.us-east-2.amazonaws.com:2182")
if err != nil {
    fmt.Println(err.Error())
}

The connection is not established, and the error returned is

"failed to dial: failed to open connection to z-2...us-east-2.amazonaws.com:2182: dial tcp 172.<>.<>.<>:2182: i/o timeout"

Why does this return the error even though the secret is added in the dialer mechanism?

0

There are 0 answers