Internal call graph ▹
Internal call graph ▾
In the call graph viewer below, each node is a function belonging to this package and its children are the functions it calls—perhaps dynamically.
The root nodes are the entry points of the package: functions that may be called from outside the package. There may be non-exported or anonymous functions among them if they are called dynamically from another package.
Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring
Functions may be omitted if they were determined to be unreachable in the particular programs or tests that were analyzed.
func BuildAuthToken ¶
func BuildAuthToken(endpoint, region, dbUser string, creds *credentials.Credentials) (string, error)
BuildAuthToken will return a authentication token for the database's connect based on the RDS database endpoint, AWS region, IAM user or role, and AWS credentials.
Endpoint consists of the hostname and port, IE hostname:port, of the RDS database. Region is the AWS region the RDS database is in and where the authentication token will be generated for. DbUser is the IAM user or role the request will be authenticated for. The creds is the AWS credentials the authentication token is signed with.
An error is returned if the authentication token is unable to be signed with the credentials, or the endpoint is not a valid URL.
The following example shows how to use BuildAuthToken to create an authentication token for connecting to a MySQL database in RDS.
authToken, err := BuildAuthToken(dbEndpoint, awsRegion, dbUser, awsCreds) // Create the MySQL DNS string for the DB connection // user:password@protocol(endpoint)/dbname?<params> dnsStr = fmt.Sprintf("%s:%s@tcp(%s)/%s?tls=true", dbUser, authToken, dbEndpoint, dbName, ) // Use db to perform SQL operations on database db, err := sql.Open("mysql", dnsStr)
See http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html for more information on using IAM database authentication with RDS.