# B.NodeCdkLayer
![Pipeline](https://github.com/Biomapas/B.NodeCdkLayer/workflows/Pipeline/badge.svg?branch=master)
### Description
This is a simple Lambda layer AWS CDK resource that contains `node` and `aws cdk cli` within.
This package is useful for lambda functions that want to run `aws cdk` commands within themselves.
Imagine a scenario where you run `cdk deploy --all` command not within you local pc or a build environment
but through a lambda function. This library would greatly help you.
### Remarks
[Biomapas](https://www.biomapas.com/) aims to modernise life-science industry by sharing its IT knowledge with other companies and the community.
This is an open source library intended to be used by anyone.
Improvements and pull requests are welcome.
### Related technology
- Python3
- Docker
- AWS CDK
### Assumptions
This project assumes you have:
- Good knowledge in AWS.
- Good knowledge in AWS CDK.
- Good Python skills and basis of OOP.
### Useful sources
- Read more about how Docker is ued when building custom lambda layers:<br>
https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_lambda/Code.html#aws_cdk.aws_lambda.Code.from_docker_build
### Install
Before installing this library, ensure you have these tools setup:
- Python / Pip
To install this project from source run:
```
pip install .
```
Or you can install it from a PyPi repository:
```
pip install b-node-cdk-layer
```
### Usage & Examples
Simply create a lambda function with this layer:
```python
from aws_cdk.aws_lambda import Function
from b_node_cdk_layer.node_cdk_layer import NodeCdkLayer
Function(
scope=Stack(...),
id='Function',
...,
layers=[NodeCdkLayer(Stack(...))],
# Running node process requires more RAM and longer runtime.
timeout=Duration.minutes(1),
memory_size=512
)
```
To run some node or cdk command, follow this example:
```python
import subprocess
# This is the path to AWS CDK CLI. It comes from a NodeCDK layer, that is a custom-built layer using docker.
CDK_CLI_PATH = '/opt/bin/node_modules/aws-cdk/bin/cdk'
def handler(*args, **kwargs):
output = subprocess.check_output([
CDK_CLI_PATH,
'--version',
])
print(output)
```
### Testing
This package has unit tests based on **pytest**.
To run tests simply run:
```
pytest b_node_cdk_layer_test/integration
```
### Contribution
Found a bug? Want to add or suggest a new feature?
Contributions of any kind are gladly welcome.
You may contact us directly, create a pull-request or an issue in github platform.
Lets modernize the world together.
# Release history
### 0.1.0
* Release build. Package works as intended.
### 0.0.1
* Initial build.
Raw data
{
"_id": null,
"home_page": "https://github.com/biomapas/B.NodeCdkLayer.git",
"name": "b-node-cdk-layer",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "AWS CDK Lambda Layer Node",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/60/a9/90ce068c2334b4f6dbaf1d831f0650c44cc364f454f5124a7fc87b2ac26a/b_node_cdk_layer-0.1.0.tar.gz",
"platform": null,
"description": "# B.NodeCdkLayer\n\n![Pipeline](https://github.com/Biomapas/B.NodeCdkLayer/workflows/Pipeline/badge.svg?branch=master)\n\n### Description\n\nThis is a simple Lambda layer AWS CDK resource that contains `node` and `aws cdk cli` within. \nThis package is useful for lambda functions that want to run `aws cdk` commands within themselves.\nImagine a scenario where you run `cdk deploy --all` command not within you local pc or a build environment\nbut through a lambda function. This library would greatly help you.\n\n### Remarks\n\n[Biomapas](https://www.biomapas.com/) aims to modernise life-science industry by sharing its IT knowledge with other companies and the community. \nThis is an open source library intended to be used by anyone. \nImprovements and pull requests are welcome. \n\n### Related technology\n\n- Python3\n- Docker\n- AWS CDK\n\n### Assumptions\n\nThis project assumes you have:\n\n- Good knowledge in AWS. \n- Good knowledge in AWS CDK. \n- Good Python skills and basis of OOP.\n\n### Useful sources\n\n- Read more about how Docker is ued when building custom lambda layers:<br>\n https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_lambda/Code.html#aws_cdk.aws_lambda.Code.from_docker_build\n\n### Install\n\nBefore installing this library, ensure you have these tools setup:\n\n- Python / Pip\n\nTo install this project from source run:\n\n```\npip install .\n```\n\nOr you can install it from a PyPi repository:\n\n```\npip install b-node-cdk-layer\n```\n\n### Usage & Examples\n\nSimply create a lambda function with this layer:\n\n```python\nfrom aws_cdk.aws_lambda import Function\nfrom b_node_cdk_layer.node_cdk_layer import NodeCdkLayer\n\nFunction(\n scope=Stack(...),\n id='Function',\n \n ...,\n \n layers=[NodeCdkLayer(Stack(...))],\n \n # Running node process requires more RAM and longer runtime.\n timeout=Duration.minutes(1),\n memory_size=512\n)\n```\n\nTo run some node or cdk command, follow this example:\n\n```python\nimport subprocess\n\n# This is the path to AWS CDK CLI. It comes from a NodeCDK layer, that is a custom-built layer using docker.\nCDK_CLI_PATH = '/opt/bin/node_modules/aws-cdk/bin/cdk'\n\n\ndef handler(*args, **kwargs):\n output = subprocess.check_output([\n CDK_CLI_PATH,\n '--version',\n ])\n\n print(output)\n```\n\n### Testing\n\nThis package has unit tests based on **pytest**.\nTo run tests simply run:\n\n```\npytest b_node_cdk_layer_test/integration\n```\n\n### Contribution\n\nFound a bug? Want to add or suggest a new feature? \nContributions of any kind are gladly welcome. \nYou may contact us directly, create a pull-request or an issue in github platform. \nLets modernize the world together.\n\n\n# Release history\n\n### 0.1.0\n* Release build. Package works as intended.\n\n### 0.0.1\n* Initial build.\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "AWS CDK lambda layer resource that contains node and aws cdk cli packages.",
"version": "0.1.0",
"split_keywords": [
"aws",
"cdk",
"lambda",
"layer",
"node"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "bead5009926a202d8f9427f5a1a7f0be",
"sha256": "1f2a3ef0394bd9bf6aa77d880468055a2eed93ba774afb79d7848770e0e8f84a"
},
"downloads": -1,
"filename": "b_node_cdk_layer-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bead5009926a202d8f9427f5a1a7f0be",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12793,
"upload_time": "2022-12-02T11:42:10",
"upload_time_iso_8601": "2022-12-02T11:42:10.975557Z",
"url": "https://files.pythonhosted.org/packages/82/57/a3ae7a450990b5dc27cbe0b84601cdb1e7516c09ceeee9ec69064c54e84c/b_node_cdk_layer-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "d5a836c5cdc9e6c97233e2b2255773bd",
"sha256": "9c36ae2ea7a9ec97181ede89a519142bafba93172749653299afcfe7480867df"
},
"downloads": -1,
"filename": "b_node_cdk_layer-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "d5a836c5cdc9e6c97233e2b2255773bd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9596,
"upload_time": "2022-12-02T11:42:12",
"upload_time_iso_8601": "2022-12-02T11:42:12.657738Z",
"url": "https://files.pythonhosted.org/packages/60/a9/90ce068c2334b4f6dbaf1d831f0650c44cc364f454f5124a7fc87b2ac26a/b_node_cdk_layer-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-02 11:42:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "biomapas",
"github_project": "B.NodeCdkLayer.git",
"lcname": "b-node-cdk-layer"
}