@Stability(value=Stable)
See: Description
| Class | Description |
|---|---|
| InlineLambdaConstruct |
A simple CDK construct to create a Lambda function with static inline code that prints the event and calls the callback function.
|
This is a test project to test the workflow of creating a CDK construct library using projen. You can follow the steps I've executed below.
The CDK construct InlineLambdaConstruct only creates a very simple Lambda function that prints out the event it's receiving.
Did you know there are multiple ways to bundle an AWS Lambda function in a CDK construct ?
Do you have questions? Feel free to reach out via Twitter or visit my website - I'm a Freelance Software Engineer focusing on Serverless Cloud Projects.
In case you want to test projen as well, here are the steps I've performed.
mkdir projen-test cd projen-test npx projen new awscdk-construct
git init and connect an existing Git project using git remote add origin <REMOTE_URL>.
(Create your Git repository in GitHub first before you call git remote add ...)
master but your remote branch is main, then use git branch -M main to rename the local branch.alias pj='npx projen'projen options in .projenrc.js a bit. For example:
name, author, authorName, authorAddress, repositoryUrlcdkAssert: true for being able to test my CDK constructcdkDependencies: ['@aws-cdk/core', '@aws-cdk/aws-lambda'] to let projen add these CDK dependencies for medocgen: true so it automatically generates API documentation 🙌eslint: true to make sure I use common coding standardsdependabot: true and dependabotOptions: {...} to enable Dependabot because I hate managing dependency updates manuallygitignore: ['.idea'] because I love using IntelliJ ♥️ but I don't want to commit its settingsmergify: false because I haven't used it so far
releaseBranches: ['main']releaseEveryCommit: truereleaseToNpm: true -> Yes, I want to release a new version to NPM every time :)releaseWorkflow: trueprojectType: ProjectType.LIB since this one is a librarypackageManager: NodePackageManager.NPM if you want to use NPM instead of Yarn - might be important in case you are migrating an existing CDK Construct to projen.
Don't forget to add necessary imports when applying the projen settings, e.g. for ProjectType.
pj again on your command-line.
This will update all project files like package.json and similar based on what you have configured in .projenrc.js.
yarn run build.
This command will execute the tests using Jest and also generate API.md 😍
If you have followed all previous steps, you'll probably have noticed that there are a few files in .github/workflows folder. They take care of running GitHub Actions to build and release/publish the library to NPM and other repositories.
# Maybe adjust this to really add all files from every folder, or use IntelliJ or some Git GUI to do this git add . git commit -M "Initial commit"
NPM_TOKEN as name and insert the access token from the previous step.
This isgit push -u origin main.
If you have configured releaseBranches: ['main'] in .projenrc.js as discussed above, then a new Action run is triggered that builds your CDK construct and publishes it to NPM.
TODO
TODO
Copyright © 2021. All rights reserved.