This package will help you install CDK as a Lambda Layer. An example use-case for this is if you are using Lamdba as a mechanism to deploy your applications.
Here's a couple easy options for you:
Go to your Lambda and click Add a Layer
arn:aws:lambda:us-east-1:588317532452:layer:CDKaaL:1
Note: the layer is built using
nodejs12.x
and is inus-east-
. If you need another version or region, please open an issue and I can update this.
Note: this is on version 1, and last updated on 02/02/2020
git clone https://github.com/campionfellin/CDKaaL.git
cd CDKaal/nodejs
npm i
cd ..
zip -r nodejs.zip nodejs
Then go to Lamba layers and upload nodejs.zip
as your source code.
This layer can be used in 2 ways:
In your Lambda's code, you can use
import cdk = require('@aws-cdk/core');
as you normally would, without needing to upload the entire aws-cdk
node module as part of your Lambda deployment. Right now the zipped size of aws-cdk
is ~15mb and the unzipped size is ~70mb.
This will also install the AWS-CDK CLI at /opt/nodejs/cdk
so you can deploy CDK apps with your Lambda.
Example usage in a NodeJS Lambda:
const { exec } = require('child_process');
exec(`/opt/nodejs/cdk --version`, (err, stdout, stderr) => {
.
.
.
});