Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2019 02:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Karunamon/16b0ec04f6131b4ac8395745a60f7ae3 to your computer and use it in GitHub Desktop.
Boto3 with IAM roles
#!/usr/bin/env python3
import boto3
sts = bot3.client('sts')
role = sts.assume_role(
RoleArn="arn:aws:iam::ACCOUNT NUMBER:role/ROLENAME",
credentials = assumed_role_object['Credentials']
s3 = boto3.resource(
for bucket in s3_resource.buckets.all():
# use S3 appropriately from here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment