-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassumerole.py
More file actions
17 lines (12 loc) · 585 Bytes
/
assumerole.py
File metadata and controls
17 lines (12 loc) · 585 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import boto3
#use lambda role to create a sts
lclient = boto3.client('sts')
#assume the role
response = lclient.assume_role(RoleArn="arn:aws:iam::236475725625:role/ProjectOneCallQualityAccess",RoleSessionName="AthenaQueryRun")
##use the temp credential
session=boto3.Session(
aws_access_key_id=response['Credentials']['AccessKeyId'],
aws_secret_access_key=response['Credentials']['SecretAccessKey'],
aws_session_token=response['Credentials']['SessionToken'])
#create Athena instance for assumed role
client=session.client('athena',region_name='us-east-1')