Skip to content

Instantly share code, notes, and snippets.

View sengstacken's full-sized avatar

Aaron Sengstacken sengstacken

View GitHub Profile
@sengstacken
sengstacken / assume_role.py
Created August 20, 2020 22:01 — forked from DaisukeMiyamoto/assume_role.py
AWS Boto3 Assume Role example
import boto3
from boto3.session import Session
def assume_role(arn, session_name):
"""aws sts assume-role --role-arn arn:aws:iam::00000000000000:role/example-role --role-session-name example-role"""
client = boto3.client('sts')
account_id = client.get_caller_identity()["Account"]
print(account_id)