Skip to content

Commit ece9312

Browse files
committed
feat: support configuration through environment variables
1 parent 55a002a commit ece9312

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,28 @@ jupyter serverextension enable --py jupyterlab_s3_browser
2121

2222
to make sure the serverextension is enabled and then restart (stop and start) JupyterLab.
2323

24+
## Usage
25+
26+
#### Configuration
27+
28+
If you have a ~/.aws/credentials file available or have already set up role-based access then no futher configuration is necessary.
29+
30+
If you wish to configure through environment variables, you can do so using environment variables, for example:
31+
32+
bash```
33+
export JUPYTERLAB_S3_ENDPOINT="https://s3.us.cloud-object-storage.appdomain.cloud"
34+
export JUPYTERLAB_S3_ACCESS_KEY_ID="my-access-key-id"
35+
export JUPYTERLAB_S3_SECRET_ACCESS_KEY="secret"
36+
37+
```
38+
39+
You can also start without any configuration and fill in your endpoint/credentials though the form when prompted.
40+
2441
#### Amazon SageMaker
2542
2643
[View installation instructions specific to SageMaker here.](docs/SAGEMAKER.md) Thanks to [Bipin Pandey](https://github.com/Bipin007) for helping figure this out.
2744
2845
## Contributing
2946
3047
Contributions to this extension are welcome! [View CONTRIBUTING.md to get started.](docs/CONTRIBUTING.md)
48+
```

jupyterlab_s3_browser/__init__.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77
import traceback
88
from collections import namedtuple
9+
from os import environ
910

1011
import boto3
1112
import tornado.gen as gen
@@ -24,9 +25,21 @@ class S3Config(SingletonConfigurable):
2425
Allows configuration of access to an S3 api
2526
"""
2627

27-
endpoint_url = Unicode("", config=True, help="The url for the S3 api")
28-
client_id = Unicode("", config=True, help="The client ID for the S3 api")
29-
client_secret = Unicode("", config=True, help="The client secret for the S3 api")
28+
endpoint_url = Unicode(
29+
environ.get("JUPYTERLAB_S3_ENDPOINT", ""),
30+
config=True,
31+
help="The url for the S3 api",
32+
)
33+
client_id = Unicode(
34+
environ.get("JUPYTERLAB_S3_ACCESS_KEY_ID", ""),
35+
config=True,
36+
help="The client ID for the S3 api",
37+
)
38+
client_secret = Unicode(
39+
environ.get("JUPYTERLAB_S3_SECRET_ACCESS_KEY", ""),
40+
config=True,
41+
help="The client secret for the S3 api",
42+
)
3043

3144

3245
@singleton

0 commit comments

Comments
 (0)