Skip to content

Instantly share code, notes, and snippets.

@tomsing1
Created August 21, 2024 19:41
Show Gist options
  • Save tomsing1/e2bd86491cddd96cad735b9e16c60f34 to your computer and use it in GitHub Desktop.
Save tomsing1/e2bd86491cddd96cad735b9e16c60f34 to your computer and use it in GitHub Desktop.
Accessing AWS within a Google Colab using the built-in secret manager
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