Python 生成 IAM 身份验证令牌 boto3.session
Python Generating an IAM authentication token boto3.session
我正在尝试使用 https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.Python.html 上的文档。现在我被困在 session = boto3.session(profile_name='RDSCreds')。什么是 profile_name 以及如何在我的 RDS 中找到它?
import sys
import boto3
ENDPOINT="mysqldb.123456789012.us-east-1.rds.amazonaws.com"
PORT="3306"
USR="jane_doe"
REGION="us-east-1"
os.environ['LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN'] = '1'
#gets the credentials from .aws/credentials
session = boto3.Session(profile_name='RDSCreds')
client = session.client('rds')
token = client.generate_db_auth_token(DBHostname=ENDPOINT, Port=PORT, DBUsername=USR, Region=REGION)
session = boto3.Session(profile_name='RDSCreds')
profile_name 此处表示您配置用于 aws cli 的配置文件的名称。
通常当您 运行 aws configure
它会创建默认值 profile.But 有时用户希望使用另一个帐户凭据或对另一个区域的管理请求来管理 aws cli,以便他们配置单独的配置文件。 docs for creating configuring multiple profiles
aws configure --profile RDSCreds #enter your access keys for this profile
如果您认为自己已经创建 RDSCreds profile
以检查该配置文件less ~/.aws/config
您提到的使用 boto3 的 rds 的文档还说 “代码示例使用配置文件共享凭证。有关指定凭证的信息,请参阅 AWS SDK 中的 Credentials Python (Boto3) 文档。"
我正在尝试使用 https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.Python.html 上的文档。现在我被困在 session = boto3.session(profile_name='RDSCreds')。什么是 profile_name 以及如何在我的 RDS 中找到它?
import sys
import boto3
ENDPOINT="mysqldb.123456789012.us-east-1.rds.amazonaws.com"
PORT="3306"
USR="jane_doe"
REGION="us-east-1"
os.environ['LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN'] = '1'
#gets the credentials from .aws/credentials
session = boto3.Session(profile_name='RDSCreds')
client = session.client('rds')
token = client.generate_db_auth_token(DBHostname=ENDPOINT, Port=PORT, DBUsername=USR, Region=REGION)
session = boto3.Session(profile_name='RDSCreds')
profile_name 此处表示您配置用于 aws cli 的配置文件的名称。
通常当您 运行 aws configure
它会创建默认值 profile.But 有时用户希望使用另一个帐户凭据或对另一个区域的管理请求来管理 aws cli,以便他们配置单独的配置文件。 docs for creating configuring multiple profiles
aws configure --profile RDSCreds #enter your access keys for this profile
如果您认为自己已经创建 RDSCreds profile
以检查该配置文件less ~/.aws/config
您提到的使用 boto3 的 rds 的文档还说 “代码示例使用配置文件共享凭证。有关指定凭证的信息,请参阅 AWS SDK 中的 Credentials Python (Boto3) 文档。"