Deploy Lambda container image with Bash script support in AWS CDK
Project description
cdk-lambda-bash
Deploy Lambda container image with Bash script support in AWS CDK
Why
AWS Lambda has the docker container image support since AWS re:Invent 2020 which allows you to run your Lambda code in a custom container image. Inspired by nikovirtala/cdk-eks-experiment, cdk-lambda-bash
allows you to specify a local shell script and bundle it up as a custom resource in your cdk stack. On cdk deployment, your shell script will be executed in a Lambda container environment.
BashExecFunction
At this moment, we are offering BashExecFunction
construct class which is a high-level abstraction of lambda.Function
. By defining the script
property which poins to your local shell script, on cdk deploy
, this script will be bundled into a custom docker image and published as a lambda.DockerImageFunction
.
If you fn.run()
, a custom resource will be created and the lambda.DockerImageFunction
will be executed on deployment.
Sample
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
app = cdk.App()
stack = cdk.Stack(app, "my-stack")
# bundle your Lambda function to execute the local demo.sh in container
fn = BashExecFunction(stack, "Demo",
script=path.join(__dirname, "../demo.sh")
)
# run it as custom resource on deployment
fn.run()
In Action
See this tweet
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
Built Distribution
Hashes for cdk_lambda_bash-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c3a2486c8e2b31c3cf74e182156c06ddcb63b17d13389e7705d8f01b9b9c712 |
|
MD5 | 1e2e1baf67f720d9a18f3ba385ce21f5 |
|
BLAKE2b-256 | 16aec56b3eed47c75a3d2ce5f9e985e3f9139e773a00e60b45d3114bee22b268 |