CDK-Klayers
Use Klayers within your CDK Stacks.
Install
pip install cdk-klayers
Usage (short version)
Simply use the Klayers Class within your CDK Stack. You will need to specify a runtime and region for it to work.
from cdk_klayers import Klayers
class MockStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
runtime = aws_lambda.Runtime.PYTHON_3_12
# Initialize Klayers
klayers = Klayers(
self,
python_version = runtime
region = "ap-southeast-1"
)
# get the latest layer version for the requests package
requests_layer = klayers.layer_version(self, "requests")
lambda_function = aws_lambda.Function(
self, 'HelloHandler',
runtime=runtime,
layers=[requests_layer],
code=aws_lambda.Code.from_asset('lambda'),
hand
Usage (long version)
This example shows a fully working CDK stack that deploys a single lambda function with 2 layers from Klayers. The region of the stack was inferred from the CDK Environment.
from aws_cdk import aws_lambda
from aws_cdk import App, Environment, Stack
from aws_cdk import Aws
from constructs import Construct
from cdk_klayers import Klayers
class MockStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
runtime = aws_lambda.Runtime.PYTHON_3_12
# Initialize Klayers
klayers = Klayers(
self,
python_version = runtime
)
# get the latest layer version for the requests package
requests_layer = klayers.layer_version(self, "requests")
idna_layer = klayers.layer_version(self, "idna", layer_version="2")
lambda_function = aws_lambda.Function(
self, 'HelloHandler',
runtime=runtime,
layers=[requests_layer, idna_layer],
code=aws_lambda.Code.from_asset('lambda'),
handler='hello.handler'
)
app = App()
env = Environment(region="us-east-1")
mock_stack =MockStack(app, "test", env=env)
Other Notes
We're still in beta, this might change. Please raise an issue if you have any feedback.
Metadata
Release files for cdk-klayers 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cdk_klayers-0.3.0.tar.gz | 3.5 kB | Without provenance | Details for cdk_klayers-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cdk_klayers-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cdk_klayers-0.3.0-py3-none-any.whl |
Total release size: 7.8 kB
Release files / cdk_klayers-0.3.0.tar.gz
| Download URL | cdk_klayers-0.3.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62aba1f9e570db70a25e5bfa7aad430c3186f8162f9850e60363786c89a6d3ca
|
|
BLAKE2b-256 checksum How to use checksums |
6555dd495f876fbba32514ead56e68ef381afcf74ee8180d96d2600dabb197f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Darwin/23.6.0
|
Release files / cdk_klayers-0.3.0-py3-none-any.whl
| Download URL | cdk_klayers-0.3.0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7477895bcbce9863eaebac102a85b42a97557e66f6186ba9feadb95363c894d4
|
|
BLAKE2b-256 checksum How to use checksums |
b6677362c7e6229f3464f3977ec32b55ae7fd1b6720a11077cb71037ced6b28f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Darwin/23.6.0
|
Security for cdk-klayers 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.