Created
September 11, 2019 13:18
-
-
Save takakabe/d39481b7a0d5e5d3fe2d234878f5b26b to your computer and use it in GitHub Desktop.
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
sts = boto3.client('sts') | |
iam_role_arn = 'arn:aws:iam::123456789012:role/wawawa_role' | |
response = sts.assume_role( | |
RoleArn=iam_role_arn, | |
RoleSessionName='wawawa' | |
) | |
session = boto3.Session( | |
aws_access_key_id=response['Credentials']['AccessKeyId'], | |
aws_secret_access_key=response['Credentials']['SecretAccessKey'], | |
aws_session_token=response['Credentials']['SessionToken'], | |
region_name='ap-northeast-1' | |
) | |
role_sts = session.client('sts') | |
print(role_sts.get_caller_identity()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment