runway.core.providers.aws.s3 package

AWS S3 objects.

class runway.core.providers.aws.s3.Bucket(context: Union[CfnginContext, RunwayContext], name: str, region: Optional[str] = None)[source]

Bases: object

AWS S3 bucket.

Instantiate class.

Parameters
  • context – Current context object.

  • name – The name of the bucket.

  • region – The bucket’s region.

property client

Create or reuse a boto3 client.

property exists

Check whether the bucket exists.

Opposite of not_found.

property forbidden

Check whether access to the bucket is forbidden.

property head

Check if a bucket exists and you have permission to access it.

To use this operation, the user must have permissions to perform the s3:ListBucket action.

This is a low level action that returns the raw result of the request.

property not_found

Check whether the bucket exists.

property session

Create cached boto3 session.

create(**kwargs: Any)Optional[CreateBucketOutputTypeDef][source]

Create an S3 Bucket if it does not already exist.

Bucket creation will be skipped if it already exists or access is forbidden.

Keyword arguments are passed directly to the boto3 method.

Returns

boto3 response.

enable_versioning()None[source]

Enable versioning on the bucket if not already enabled.

format_bucket_path_uri(*, key: Optional[str] = None, prefix: Optional[str] = None)str[source]

Format bucket path URI.

Parameters
  • key – S3 object key.

  • prefix – Directory tree to append to key.

Returns

S3 bucket URI in s3://{bucket-name}/{prefix}/{key} format

get_versioning()GetBucketVersioningOutputTypeDef[source]

Get the versioning state of a bucket.

To retrieve the versioning state of a bucket, you must be the bucket owner.

Returns

The current versioning state of the bucket containing Status and MFADelete (only if this has ever been configured).

sync_from_local(src_directory: str, *, delete: bool = False, exclude: Optional[List[str]] = None, follow_symlinks: bool = False, include: Optional[List[str]] = None, prefix: Optional[str] = None)None[source]

Sync local directory to the S3 Bucket.

Parameters
  • src_directory – Local directory to sync to S3.

  • delete – If true, files that exist in the destination but not in the source are deleted.

  • exclude – List of patterns for files/objects to exclude.

  • follow_symlinks – If symlinks should be followed.

  • include – List of patterns for files/objects to explicitly include.

  • prefix – Optional prefix to append to synced objects.

sync_to_local(dest_directory: str, *, delete: bool = False, exclude: Optional[List[str]] = None, follow_symlinks: bool = False, include: Optional[List[str]] = None, prefix: Optional[str] = None)None[source]

Sync S3 bucket to local directory.

Parameters
  • dest_directory – Local directory to sync S3 objects to.

  • delete – If true, files that exist in the destination but not in the source are deleted.

  • exclude – List of patterns for files/objects to exclude.

  • follow_symlinks – If symlinks should be followed.

  • include – List of patterns for files/objects to explicitly include.

  • prefix – Optional prefix to append to synced objects.