def get_session(profile_config):
session_profile = profile_config['profile_name']
if 'source_profile' in profile_config:
session_profile = profile_config['source_profile']
if 'region' in profile_config:
os.putenv('AWS_DEFAULT_REGION', profile_config['region'])
os.putenv('AWS_REGION', profile_config['region'])
# Create a session using profile or EC2 Instance Role
# To use Instance Role set `source_profile` to empty string in aws profile
# configuration file
session = boto3.Session(profile_name=session_profile)
return session
评论列表
文章目录