Skip to main content

No project description provided

Project description

CDK-Klayers

Python package for using Klayers within your CDK Stacks.

Python 3.12 Code style: black

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


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)

Uploaded Source

Built Distribution

cdk_klayers-0.2.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page