Created
August 21, 2024 19:41
-
-
Save tomsing1/e2bd86491cddd96cad735b9e16c60f34 to your computer and use it in GitHub Desktop.
Accessing AWS within a Google Colab using the built-in secret manager
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 | |
from google.colab import userdata | |
# refresh the temporary credentials via the key symbol in the left hand tab | |
s3_resource = boto3.resource('s3', | |
aws_access_key_id=userdata.get('AWS_ACCESS_KEY_ID'), | |
aws_secret_access_key=userdata.get('AWS_SECRET_ACCESS_KEY'), | |
aws_session_token=userdata.get('AWS_SESSION_TOKEN') | |
) | |
for bucket in s3_resource.buckets.all(): | |
print(bucket.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment