无法使用rdsutils.BuildAuthToken连接到RDS

时间:2018-01-07 03:39:49

标签: amazon-web-services go amazon-rds

我按照the official documentation中的每一步操作,并使用完全相同的代码段。

当我用硬编码的密码替换authToken时,连接将成功。

我已分配用户程序访问权限,但没有分配政策。

//Yes Env vars are available
//creating new credentials from environment variables
//AWS_ACCESS_KEY_ID  and  AWS_SECRET_ACCESS_KEY
awsCreds := credentials.NewEnvCredentials()

//creating authentication token for the database connection
authToken, err := rdsutils.BuildAuthToken(dbEndpoint, awsRegion, dbUser, awsCreds)
if err != nil {
    Logger.LogFatal("Unable to build Authentication Token")
    log.Fatal("Unable to build Authentication Token")  //todo remove
}

//setting up TLS
mysql.RegisterTLSConfig("custom", &tls.Config{
    InsecureSkipVerify: true,
})

// Creating the MySQL DNS string for the DB connection
// user:password@protocol(endpoint)/dbname?<params>
dnsStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?tls=custom",
    dbUser, authToken, dbEndpoint,dbPort, dbName,
)
database, err = sql.Open("mysql", dnsStr)

我还在努力解决这个问题。这是我收到的错误消息:

error: ERROR: Error 1045: Access denied for user 'master'@'x.x.x.189' (using password: YES)

0 个答案:

没有答案
相关问题