runway.s3_util module

Utility functions for S3.

runway.s3_util.purge_and_delete_bucket(bucket_name, region='us-east-1', session=None)[source]

Delete all objects and versions in bucket, then delete bucket.

runway.s3_util.purge_bucket(bucket_name, region='us-east-1', session=None)[source]

Delete all objects and versions in bucket.

runway.s3_util.delete_bucket(bucket_name, region='us-east-1', session=None)[source]

Delete bucket.

runway.s3_util.does_bucket_exist(bucket_name, region='us-east-1', session=None)[source]

Check if bucket exists in S3.

runway.s3_util.ensure_bucket_exists(bucket_name, region='us-east-1', session=None)[source]

Ensure S3 bucket exists.

runway.s3_util.does_s3_object_exist(bucket, key, session=None, region='us-east-1')[source]

Determine if object exists on s3.

runway.s3_util.upload(bucket, key, filename, session=None)[source]

Upload file to S3 bucket.

runway.s3_util.download(bucket, key, file_path, session=None)[source]

Download a file from S3 to the given path.

runway.s3_util.download_and_extract_to_mkdtemp(bucket, key, session=None)[source]

Download zip archive and extract it to temporary directory.

runway.s3_util.get_matching_s3_objects(bucket, prefix='', suffix='', session=None)[source]

Generate objects in an S3 bucket.

Parameters
  • bucket – Name of the S3 bucket.

  • prefix – Only fetch objects whose key starts with this prefix (optional).

  • suffix – Only fetch objects whose keys end with this suffix (optional).

  • session – Boto3/botocore session.

runway.s3_util.get_matching_s3_keys(bucket, prefix='', suffix='', session=None)[source]

Generate the keys in an S3 bucket.

Parameters
  • bucket – Name of the S3 bucket.

  • prefix – Only fetch keys that start with this prefix (optional).

  • suffix – Only fetch keys that end with this suffix (optional).

  • session – Boto3/botocore session.