def create_boto_sts_client(profileName=None, secretAccessKey=None, accessKeyId=None, sessionToken=None):
"""
profileName - the name of the profile to create the client with;
secretAccessKey - secret access key that can be passed into the session;
accessKeyId - access key id that can be passed into the session;
sessionToken - session token that can be passed into the session;
return a boto3 session client
"""
log.info('Creating a Boto3 STS client')
log.debug('profile_name=' + str(profileName))
log.debug('aws_access_key_id=' + str(accessKeyId))
log.debug('aws_secret_access_key=' + str(secretAccessKey))
log.debug('aws_session_token=' + str(sessionToken))
#establish the boto session with given credentials
botoSession = boto3.Session(profile_name=profileName,
aws_access_key_id=accessKeyId,
aws_secret_access_key=secretAccessKey,
aws_session_token=sessionToken)
#create an sts client, always defaulted to us-east-1
return botoSession.client('sts', region_name='us-east-1')
评论列表
文章目录