在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:uktrade/jupyters3开源软件地址:https://github.com/uktrade/jupyters3开源编程语言:Python 100.0%开源软件介绍:Jupyter S3Jupyter Notebook Contents Manager for AWS S3. Installation
ConfigurationTo configure Jupyter Notebook to use JupyterS3, you can add the following to your notebook config file. from jupyters3 import JupyterS3, JupyterS3SecretAccessKeyAuthentication
c = get_config()
c.NotebookApp.contents_manager_class = JupyterS3 and must also set the following settings on
You must also, either, authenticate using a secret key, in which case you must have the following configuration from jupyters3 import JupyterS3SecretAccessKeyAuthentication
c.JupyterS3.authentication_class = JupyterS3SecretAccessKeyAuthentication and the following settings on
or authenticate using a role in an ECS container, in which case you must have the following configuration from jupyters3 import JupyterS3ECSRoleAuthentication
c.JupyterS3.authentication_class = JupyterS3ECSRoleAuthentication where JupyterS3ECSRoleAuthentication does not have configurable options, or write your own authentication class, such as the one below for EC2/IAM role-based authentication import datetime
import json
from jupyters3 import (
AwsCreds,
JupyterS3Authentication,
)
from tornado import gen
from tornado.httpclient import (
AsyncHTTPClient,
HTTPError as HTTPClientError,
HTTPRequest,
)
class JupyterS3EC2RoleAuthentication(JupyterS3Authentication):
role_name = Unicode(config=True)
aws_access_key_id = Unicode()
aws_secret_access_key = Unicode()
pre_auth_headers = Dict()
expiration = Datetime()
@gen.coroutine
def get_credentials(self):
now = datetime.datetime.now()
if now > self.expiration:
request = HTTPRequest('http://169.254.169.254/latest/meta-data/iam/security-credentials/' + self.role_name, method='GET')
creds = json.loads((yield AsyncHTTPClient().fetch(request)).body.decode('utf-8'))
self.aws_access_key_id = creds['AccessKeyId']
self.aws_secret_access_key = creds['SecretAccessKey']
self.pre_auth_headers = {
'x-amz-security-token': creds['Token'],
}
self.expiration = datetime.datetime.strptime(creds['Expiration'], '%Y-%m-%dT%H:%M:%SZ')
return AwsCreds(
access_key_id=self.aws_access_key_id,
secret_access_key=self.aws_secret_access_key,
pre_auth_headers=self.pre_auth_headers,
) configured using c.JupyterS3.authentication_class = JupyterS3EC2RoleAuthentication
c.JupyterS3EC2RoleAuthentication.role_name = 'my-iam-role-name' Differences from S3Contents
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论