foundation¶
Path and S3 layout managers for Lambda source deployment artifacts.
Defines two pure-convention layout classes that encode the directory structure used by the Lambda source build workflow:
SourcePathLayout— local filesystem paths under{dir_project_root}/build/lambda/source/SourceS3Layout— S3 paths whose root is thesource/-scoped S3 directory, e.g.s3://bucket/path/to/lambda/source/
Neither class performs I/O; they only compute paths so callers can stay decoupled from the hard-coded directory names.
Relationship to the higher-level s3dir_lambda prefix¶
s3dir_lambda is a shared parent used by multiple artifact types (source,
layer, …). Each type owns a scoped sub-prefix so that “delete everything
under this layout’s root” is safe and never touches sibling artifacts.
SourceS3Layout is constructed directly with the already-scoped
source/ directory as dir_root. Use the convenience factory
SourceS3Layout.from_s3dir_lambda() to derive that scoped root
automatically from the shared s3dir_lambda parent.
- class aws_lbd_art_builder_core.source.foundation.SourcePathLayout(dir_root: Path = REQ)[source]¶
Local filesystem path layout for Lambda source build artifacts.
- Parameters:
dir_root – Root directory for source artifacts, e.g.
/path/to/git-repo/build/lambda/source
Layout:
{dir_root}/build/ ← pip install target (temporary files) {dir_root}/source.zip ← final deployment package
- class aws_lbd_art_builder_core.source.foundation.SourceS3Layout(dir_root: S3Path = REQ)[source]¶
S3 path layout manager for Lambda source artifacts.
The root is scoped to the source-specific S3 directory so that operations such as “delete everything under root” only affect source artifacts and never accidentally touch sibling prefixes (e.g.
layer/).- Parameters:
dir_root – Source-specific S3 root directory, e.g.
s3://bucket/path/to/lambda/source/
Layout, see
get_s3path_source_zip():{dir_root}/0.1.1/{source_sha256}/source.zip {dir_root}/0.1.2/{source_sha256}/source.zip {dir_root}/0.1.3/{source_sha256}/source.zip ...
- classmethod from_s3dir_lambda(s3dir_lambda: S3Path) SourceS3Layout[source]¶
Derive a
SourceS3Layoutfrom the shared Lambda S3 base directory.s3dir_lambdais the higher-level anchor shared by all Lambda artifact types (source, layer, …). This factory pins the root to thesource/sub-prefix, giving the source layout an isolated namespace.- Parameters:
s3dir_lambda – Base S3 directory for Lambda artifacts, e.g.
s3://bucket/path/to/lambda/- Returns:
SourceS3Layoutrooted at{s3dir_lambda}/source/
- get_s3path_source_zip(source_version: str, source_sha256: str) S3Path[source]¶
Generate S3 path for a specific version of the Lambda source zip.
- Parameters:
source_version – Semantic version string, e.g.,
"0.1.1"source_sha256 – SHA256 hash of the source build directory
- Returns:
S3Path pointing to the versioned source.zip file, e.g.
{dir_root}/{source_version}/{source_sha256}/source.zip
Note
Including the SHA256 hash in the path ensures that any code change produces a new S3 key, which forces CDK / CloudFormation / AWS APIs to recognise and deploy the updated Lambda function code.