How to use the s3contents.S3ContentsManager function in s3contents

To help you get started, we’ve selected a few s3contents examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danielfrg / s3contents / jupyter_notebook_config.py View on Github external
import os

from notebook.auth import passwd
from s3contents import S3ContentsManager

c = get_config()

# Tell Jupyter to use S3ContentsManager for all storage.
c.NotebookApp.contents_manager_class = S3ContentsManager
c.S3ContentsManager.access_key_id = os.environ["AWS_ACCESS_KEY_ID"]
c.S3ContentsManager.secret_access_key = os.environ["AWS_SECRET_ACCESS_KEY"]
#c.S3ContentsManager.session_token = ""
c.S3ContentsManager.bucket = os.environ["S3_BUCKET"]

# Optional settings:
c.S3ContentsManager.prefix = os.environ.get("S3_PREFIX", "notebooks/")
#c.S3ContentsManager.signature_version = "s3v4"

# If SSE S3 encryption is needed
#c.S3ContentsManager.sse = "AES256"

# If SSE KMS encryption is needed using a CMK
#c.S3ContentsManager.sse = "aws:kms"
#c.S3ContentsManager.kms_key_id = "arn:aws:kms:us-east-1:123456789012:alias/KMS_KEY"
github heroku / heroku-jupyterlab / config.py View on Github external
try:
    AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
    AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
    S3_BUCKET_NAME = os.environ['S3_BUCKET_NAME']
except (NameError, KeyError):
    print('Using Bucketeer instead…')
    # Bucketeer addon.
    AWS_ACCESS_KEY_ID = os.environ['BUCKETEER_AWS_ACCESS_KEY_ID']
    AWS_SECRET_ACCESS_KEY = os.environ['BUCKETEER_AWS_SECRET_ACCESS_KEY']
    S3_BUCKET_NAME = os.environ['BUCKETEER_BUCKET_NAME']

PASSWORD = os.environ.get('PASSWORD', '')

# c = get_config()
c.NotebookApp.contents_manager_class = S3ContentsManager
c.S3ContentsManager.access_key_id = AWS_ACCESS_KEY_ID
c.S3ContentsManager.secret_access_key = AWS_SECRET_ACCESS_KEY
c.S3ContentsManager.bucket = S3_BUCKET_NAME

c.NotebookApp.token = ''
c.NotebookApp.password = PASSWORD