Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/more s3 providers #505

Merged
merged 2 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,30 @@ S3 Bucket for snapshot upload
EXPLORER_S3_BUCKET = None


S3 region
******************

S3 region. Defaults to us-east-1 if not specified.

.. code-block:: python

EXPLORER_S3_REGION = 'us-east-1'



S3 endpoint url
******************

S3 endpoint url. Normally not necessary to set.
Useful to set if you are using a non-AWS S3 service or you are using a private AWS endpoint.


.. code-block:: python

EXPLORER_S3_ENDPOINT_URL = 'https://accesspoint.vpce-abc123-abcdefgh.s3.us-east-1.vpce.amazonaws.com'



S3 link expiration
******************

Expand All @@ -236,7 +260,7 @@ Links are generated as presigned urls for security

.. code-block:: python

EXPLORER_S3_S3_LINK_EXPIRATION = 3600
EXPLORER_S3_LINK_EXPIRATION = 3600


From email
Expand Down
4 changes: 3 additions & 1 deletion explorer/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@
S3_ACCESS_KEY = getattr(settings, "EXPLORER_S3_ACCESS_KEY", None)
S3_SECRET_KEY = getattr(settings, "EXPLORER_S3_SECRET_KEY", None)
S3_BUCKET = getattr(settings, "EXPLORER_S3_BUCKET", None)
S3_LINK_EXPIRATION: int = getattr(settings, "EXPLORER_S3_S3_LINK_EXPIRATION", 3600)
S3_LINK_EXPIRATION: int = getattr(settings, "EXPLORER_S3_LINK_EXPIRATION", 3600)
FROM_EMAIL = getattr(
settings, 'EXPLORER_FROM_EMAIL', '[email protected]'
)
S3_REGION = getattr(settings, "EXPLORER_S3_REGION", "us-east-1")
S3_ENDPOINT_URL = getattr(settings, "EXPLORER_S3_ENDPOINT_URL", None)

UNSAFE_RENDERING = getattr(settings, "EXPLORER_UNSAFE_RENDERING", False)

Expand Down
11 changes: 8 additions & 3 deletions explorer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,14 @@ def get_valid_connection(alias=None):


def get_s3_bucket():
s3 = boto3.resource('s3',
aws_access_key_id=app_settings.S3_ACCESS_KEY,
aws_secret_access_key=app_settings.S3_SECRET_KEY)
kwargs = {
'aws_access_key_id': app_settings.S3_ACCESS_KEY,
'aws_secret_access_key': app_settings.S3_SECRET_KEY,
'region_name': app_settings.S3_REGION
}
if app_settings.S3_ENDPOINT_URL:
kwargs['endpoint_url'] = app_settings.S3_ENDPOINT_URL
s3 = boto3.resource('s3', **kwargs)
return s3.Bucket(name=app_settings.S3_BUCKET)


Expand Down