No project description provided
Project description
CDK-Klayers
Python package for using Klayers within your CDK Stacks.
Install
pip install cdk-klayers
Usage
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)
# Initialize Klayers
klayers = Klayers(
self,
python_version = aws_lambda.Runtime.PYTHON_3_12
)
# get the latest layer version for the requests package
requests_layer = klayers.layer_version(self, "requests")
idna_layer = klayers.layer_version(self, "idna")
lambda_function = aws_lambda.Function(
self, 'HelloHandler',
runtime= aws_lambda.Runtime.PYTHON_3_12,
layers=[requests_layer, idna_layer],
code=aws_lambda.Code.from_asset('lambda'),
handler='hello.handler'
# other props
)
app = App()
# region must be specified in environment or within the Klayers __init__
env = Environment(region="us-east-1")
mock_stack =MockStack(app, "test", env=env)
Other Notes
We're still in beta. Currently we've only tested in Python 3.12, but will extend support for python 3.11, and python 3.10 soon as well.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cdk_klayers-0.2.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for cdk_klayers-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58f33e237f1e2a9c86e915b2f5386a28eace3e00b461420d1853ae3a04398534 |
|
MD5 | e753a8c116f9869bc09ea33280e29217 |
|
BLAKE2b-256 | f1b2ef66867f25bb62ad774fa1b72d5d00e2304f559ce528fbd224d22d3242ad |