Created
September 7, 2020 09:11
-
-
Save rjurney/034843ca36e01c00d56cdecd2f77a1d1 to your computer and use it in GitHub Desktop.
How to securely or insecurely get your code from Amazon S3 in Colab
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
#!/bin/bash | |
# Copy files to S3 | |
aws s3 cp myfile.py s3://mybucket/ | |
aws s3 cp config.py s3://mybucket/ |
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 | |
import getpass | |
# | |
# Note: you can use passlib to get these securely without putting them in the notebook: | |
# | |
os.environ['AWS_ACCESS_KEY_ID'] = getpass.getpass(prompt='AWS_ACCESS_KEY_ID: ', stream=None) | |
os.environ['AWS_SECRET_ACCESS_KEY'] = getpass.getpass(prompt='AWS_SECRET_ACCESS_KEY: ', stream=None) | |
# Otherwise you can encode them yourself | |
os.environ['AWS_ACCESS_KEY_ID'] = 'MY_AWS_ACCESS_KEY_ID' | |
os.environ['AWS_SECRET_ACCESS_KEY'] = 'MY_AWS_SECRET_ACCESS_KEY' | |
s3 = boto3.client('s3') | |
s3.download_file('mybucket', 'myfile.py', 'myfile.py') | |
s3.download_file('mybucket', 'config.py', 'config.py') | |
# Import our configuration | |
from config import PARAMETERS | |
# Import our utilities that we downloaded | |
import myfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment