Created
November 10, 2021 19:01
-
-
Save Behoston/f69ffb9b345d58db077ad0fb19d04f0f to your computer and use it in GitHub Desktop.
AWS boto3 Assume Role (S3 example)
This file contains hidden or 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 | |
from botocore.client import Config | |
sts_client = boto3.client('sts') | |
assumed_role_object = sts_client.assume_role( | |
RoleArn="arn:aws:iam::111111111111:role/Administrator", | |
RoleSessionName="testing-assume-role", | |
) | |
credentials = assumed_role_object['Credentials'] | |
s3_resource = boto3.resource( | |
's3', | |
aws_access_key_id=credentials['AccessKeyId'], | |
aws_secret_access_key=credentials['SecretAccessKey'], | |
aws_session_token=credentials['SessionToken'], | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment