Name | cdk-klayers JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-08-15 01:35:06 |
maintainer | None |
docs_url | None |
author | Keith Rozario |
requires_python | <4.0,>=3.8 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![Python 3.10](https://img.shields.io/badge/python-3.10-green?style=for-the-badge)](https://www.python.org/downloads/release/python-3100/)
[![Python 3.11](https://img.shields.io/badge/python-3.11-green?style=for-the-badge)](https://www.python.org/downloads/release/python-3110/)
[![Python 3.12](https://img.shields.io/badge/python-3.12-green?style=for-the-badge)](https://www.python.org/downloads/release/python-3120/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000?style=for-the-badge)](https://github.com/psf/black)
# CDK-Klayers
Use [Klayers](https://github.com/keithrozario/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.
```python
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`.
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "cdk-klayers",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Keith Rozario",
"author_email": "keithjosephrozario@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/65/55/dd495f876fbba32514ead56e68ef381afcf74ee8180d96d2600dabb197f7/cdk_klayers-0.3.0.tar.gz",
"platform": null,
"description": "[![Python 3.10](https://img.shields.io/badge/python-3.10-green?style=for-the-badge)](https://www.python.org/downloads/release/python-3100/)\n[![Python 3.11](https://img.shields.io/badge/python-3.11-green?style=for-the-badge)](https://www.python.org/downloads/release/python-3110/)\n[![Python 3.12](https://img.shields.io/badge/python-3.12-green?style=for-the-badge)](https://www.python.org/downloads/release/python-3120/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000?style=for-the-badge)](https://github.com/psf/black)\n\n# CDK-Klayers\n\nUse [Klayers](https://github.com/keithrozario/Klayers) within your CDK Stacks.\n\n## Install\n\n pip install cdk-klayers\n\n## Usage (short version)\n\nSimply use the Klayers Class within your CDK `Stack`. You will need to specify a runtime and region for it to work.\n\n```python\n\nfrom cdk_klayers import Klayers\n\nclass MockStack(Stack):\n\n def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:\n super().__init__(scope, construct_id, **kwargs)\n\n runtime = aws_lambda.Runtime.PYTHON_3_12\n\n # Initialize Klayers \n klayers = Klayers(\n self,\n python_version = runtime\n region = \"ap-southeast-1\"\n )\n \n # get the latest layer version for the requests package\n requests_layer = klayers.layer_version(self, \"requests\")\n\n lambda_function = aws_lambda.Function(\n self, 'HelloHandler',\n runtime=runtime,\n layers=[requests_layer],\n code=aws_lambda.Code.from_asset('lambda'),\n hand\n\n```\n\n## Usage (long version)\n\nThis 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`.\n\n```python\n\nfrom aws_cdk import aws_lambda\nfrom aws_cdk import App, Environment, Stack\nfrom aws_cdk import Aws\nfrom constructs import Construct\n\nfrom cdk_klayers import Klayers\n\nclass MockStack(Stack):\n\n def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:\n super().__init__(scope, construct_id, **kwargs)\n\n runtime = aws_lambda.Runtime.PYTHON_3_12\n\n # Initialize Klayers \n klayers = Klayers(\n self,\n python_version = runtime\n )\n \n # get the latest layer version for the requests package\n requests_layer = klayers.layer_version(self, \"requests\")\n idna_layer = klayers.layer_version(self, \"idna\", layer_version=\"2\")\n\n lambda_function = aws_lambda.Function(\n self, 'HelloHandler',\n runtime=runtime,\n layers=[requests_layer, idna_layer],\n code=aws_lambda.Code.from_asset('lambda'),\n handler='hello.handler'\n )\n\n\napp = App()\nenv = Environment(region=\"us-east-1\")\nmock_stack =MockStack(app, \"test\", env=env)\n```\n\n## Other Notes\n\nWe're still in beta, this might change. Please raise an issue if you have any feedback.",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.3.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b6677362c7e6229f3464f3977ec32b55ae7fd1b6720a11077cb71037ced6b28f",
"md5": "3b1ad62dba72d6d85abe2475eaa05595",
"sha256": "7477895bcbce9863eaebac102a85b42a97557e66f6186ba9feadb95363c894d4"
},
"downloads": -1,
"filename": "cdk_klayers-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3b1ad62dba72d6d85abe2475eaa05595",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 4251,
"upload_time": "2024-08-15T01:35:04",
"upload_time_iso_8601": "2024-08-15T01:35:04.894664Z",
"url": "https://files.pythonhosted.org/packages/b6/67/7362c7e6229f3464f3977ec32b55ae7fd1b6720a11077cb71037ced6b28f/cdk_klayers-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6555dd495f876fbba32514ead56e68ef381afcf74ee8180d96d2600dabb197f7",
"md5": "19f349ce67ae5c0ffad2c6fab3ea3a18",
"sha256": "62aba1f9e570db70a25e5bfa7aad430c3186f8162f9850e60363786c89a6d3ca"
},
"downloads": -1,
"filename": "cdk_klayers-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "19f349ce67ae5c0ffad2c6fab3ea3a18",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 3509,
"upload_time": "2024-08-15T01:35:06",
"upload_time_iso_8601": "2024-08-15T01:35:06.320093Z",
"url": "https://files.pythonhosted.org/packages/65/55/dd495f876fbba32514ead56e68ef381afcf74ee8180d96d2600dabb197f7/cdk_klayers-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-15 01:35:06",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cdk-klayers"
}