route1io_connectors.aws module
AWS
This module contains convenience functionality for working with AWS.
References
- AWS SDK for Python (Boto3)
- connect_to_s3(aws_access_key_id: str, aws_secret_access_key: str, region_name: str)
Returns a connection to s3 bucket via AWS
- Parameters
aws_access_key_id (str) – AWS access key
aws_secret_access_key (str) – AWS secret access key
region_name (str) – Default region name
- Returns
Connection to s3 bucket via AWS
- Return type
s3
- download_from_s3(s3, bucket: str, key: str, filename: Optional[str] = None) List[str]
Download file via AWS s3 bucket and return the fpath to the local file
- Parameters
s3 – Connection to s3 bucket
bucket (str) – Name of s3 bucket to download file from
key (str) – Remote filename to download from the bucket
- get_most_recent_filename(s3, bucket: str, prefix: str = '') str
Return the key name as it appears in s3 bucket of the most recently modified file in bucket
- Parameters
s3 – Connection to AWS S3 bucket
bucket (str) – Name of the bucket that contains data we want
prefix (str, optional) – Prefix to filter data
- Returns
Name of the most recently modified file as it appears in S3 bucket
- Return type
key
- upload_to_s3(s3, bucket: str, filename: Union[str, Sequence[str]], key: Optional[Union[str, Sequence[str]]] = None) None
Uploads a file to AWS s3 bucket
- Parameters
s3 – Connection to s3 bucket
filename (str) – Local filepath of file to be uploaded
bucket (str) – Name of s3 bucket to upload file to
key (str (optional)) – Remote filename to upload file as