PyUpdater icon indicating copy to clipboard operation
PyUpdater copied to clipboard

added support for private amazon S3 bucket connectivity. Just pass in…

Open jrj99 opened this issue 3 years ago • 1 comments

added support for private amazon S3 bucket connectivity. Just pass in the s3_params dictionary (documentation will be provided later) when creating a new PyUpdater object if you want to enable this feature.

Documentation for s3_params (and my changes):

s3_params should contain 6 dictionary keywords:

host: this is the hostname where your aws bucket is located. (example: 's3-us-west-2.amazonaws.com'). region: this is the region where your AWS bucket is located. (example: 'us-west-2'). endpoint: URL where your bucket will be located. (example: 'https://s3-us-west-2.amazonaws.com') access_key: Access key used to access your AWS bucket (example: '1234') secret_key: Secret Access key used to access a protected AWS bucket (example: 'abcd') bucket_name: Name of your aws bucket (example: 'bucket')

There is also an optional keyword you can use: request_parameters(OPTIONAL): additional AWS parameters.

Example s3_params dictionary:

The following is a valid s3_params dictionary, we will call it s3_dict:

s3_dict = {'host': 's3-us-west-2.amazonaws.com', 'region': 'us-west-2', 'endpoint': 'https://s3-us-west-2.amazonaws.com',
        'access_key': '1234', 'bucket_name': 'summit-esp-bench-updates/motor_bench'}

To use s3_dict connect to a private AWS bucket in your client, do the following:

from pyupdater.client import Client

aws_headers= {'Host': 's3-us-west-2.amazonaws.com'}        

update_client = Client(CLIENT_CONFIG, refresh=True, headers=aws_unprotected_headers, s3_params=s3_dict)

the aws hostname MUST be passed in the header params for the client (as outlined in the above code)! A connection won't be made otherwise. Also, make sure that the full URL to your bucket that you are connecting to is present in your update_urls list in your client. (i.e UPDATE_URLS = ['https://s3-us-west-2.amazonaws.com/bucket'])

jrj99 avatar Jan 10 '22 22:01 jrj99

@jrj99 Thanks for the PR! My apologies for getting to this so late.

JMSwag avatar Jan 30 '22 18:01 JMSwag