quilt3.hooks

get_build_s3_client_hook() -> Optional[quilt3.hooks.BuildClientHook]

Return build S3 client hook.

set_build_s3_client_hook(hook: Optional[quilt3.hooks.BuildClientHook]) -> Optional[quilt3.hooks.BuildClientHook]

Set build S3 client hook.

Example for overriding ServerSideEncryption parameter for certain S3 operations:

def event_handler(params, **kwargs):
    # Be mindful with parameters you set here.
    # Specifically it's not recommended to override/delete already set parameters
    # because that can break quilt3 logic.
    params.setdefault("ServerSideEncryption", "AES256")

def hook(build_client_base, session, client_kwargs, **kwargs):
    client = build_client_base(session, client_kwargs, **kwargs)
    # Docs for boto3 events system we use below:
    # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/events.html
    for op in (
        "CreateMultipartUpload",
        "CopyObject",
        "PutObject",
    ):
        client.meta.events.register(f"before-parameter-build.s3.{op}", event_handler)
    return client

Arguments

  • hook: Build client hook.

Returns

Old build client hook.

Last updated

Was this helpful?