Return an authentication token used as the password for a database connection.
rds_build_auth_token(endpoint, region, user, creds)
[required] Hostname and port needed to connect
to the database: <host>:<port>
.
[required] AWS region the database is located in.
[required] User account within the database to sign in with.
Credentials to be signed with.
svc$build_auth_token( endpoint = "string", region = "string", user = "string", creds = list( access_key_id = "string", secret_access_key = "string", session_token = "string" ) )
See IAM Database Authentication for MySQL and PostgreSQL for more information on using IAM database authentication with RDS.
# NOT RUN {
# This example gets an authentication token for an RDS database, then
# connects to the database using the token.
# }
# NOT RUN {
host <- "database-1.cluster-abcdef123456.us-east-1.rds.amazonaws.com"
port <- 3306
user <- "jane_doe"
token <- svc$build_auth_token(
endpoint = sprintf("%s:%s", host, port),
region = "us-east-1",
user = user
)
# }
# NOT RUN {
conn <- DBI::dbConnect(
drv = RMariaDB::MariaDB(),
user = user,
password = token,
host = host,
port = port,
client.flag = RMariaDB::CLIENT_SSL
)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab