publish

Lambda layer publication — Step 4 of the layer workflow.

Takes the uploaded layer.zip from S3 and creates a versioned Lambda layer resource via the AWS API.

Why smart publishing?

Creating a Lambda layer version is a non-reversible, append-only operation (versions can be deleted but not overwritten). Publishing identical dependencies as a new version wastes version numbers and forces downstream stacks to update for no reason. This module compares the local dependency manifest against the previously stored one and skips the publish when nothing has changed.

class aws_lbd_art_builder_core.layer.publish.LambdaLayerVersionPublisher(verbose: bool = True, printer: ~typing.Callable[[str], None] = <built-in function print>, path_pyproject_toml: ~pathlib.Path = REQ, s3dir_lambda: S3Path = REQ, path_manifest: ~pathlib.Path = REQ, s3_client: S3Client = REQ, layer_name: str = REQ, lambda_client: LambdaClient = REQ, publish_layer_version_kwargs: dict[str, ~typing.Any] | None = None)[source]

Command class for intelligent Lambda layer version publishing.

Inherits LayerManifestManager for manifest handling and adds layer publication logic.

Why Command Pattern here?

Publishing involves multiple AWS API calls with shared state (layer name, clients, manifest path, S3 layout). Keeping these as fields on a frozen dataclass makes the publisher easy to construct, inspect, and test — same rationale as the builder classes.

run() LayerDeployment[source]

Execute the complete layer publication workflow.

step_1_preflight_check()[source]

Perform read-only validation of build environment and project configuration.

step_2_publish_layer_version() LayerDeployment[source]

Execute the layer publication workflow, creating a new Lambda layer version.

step_1_1_ensure_layer_zip_exists()[source]

Verify that the layer.zip file was successfully uploaded to S3.

is_layer_zip_exists() bool[source]

Check if the layer zip file exists in S3 temporary storage.

Returns:

True if layer.zip exists in S3, False otherwise

step_1_2_ensure_layer_zip_is_consistent()[source]

Validate that the uploaded layer.zip matches the current local manifest.

is_layer_zip_consistent() bool[source]

Compare the manifest MD5 stored in S3 metadata with the local manifest.

Returns:

True if uploaded layer.zip matches current manifest, False otherwise

step_1_3_ensure_dependencies_have_changed()[source]

Check if dependencies have changed since the last publication.

This is the core intelligence that prevents unnecessary layer version creation — skips publishing when the manifest is identical to the previously published one.

has_dependency_manifest_changed() bool[source]

Detect if the local dependency manifest has changed from the last published layer.

Returns:

True if local manifest differs from latest published version, False if they are identical (no changes detected)

step_2_1_run_publish_layer_version_api() tuple[int, str][source]

Publish a new Lambda layer version using the zip file stored in S3.

Returns:

Tuple of (layer_version_number, layer_version_arn)

step_2_2_upload_dependency_manifest(version: int) S3Path[source]

Upload the dependency manifest file to S3 for the specified layer version.

Parameters:

version – The layer version number to associate the manifest with

Returns:

S3Path where the manifest was stored

class aws_lbd_art_builder_core.layer.publish.LayerDeployment(layer_name: str = REQ, layer_version: int = REQ, layer_version_arn: str = REQ, s3path_manifest: S3Path = REQ)[source]

Immutable record of a completed layer deployment.