create-aws-cdk-app
TypeScript icon, indicating that this package has built-in type declarations

1.4.2 • Public • Published

License: MIT NPM Version codecov Typescript Semantic Release Commitizen friendly

create-aws-cdk-app

This package is an executable that uses @routineless/nx-aws-plugin to generate nx workspace with cdk and lambda applications.

Table of Contents

Install

To install this package globaly run:

npm install -g create-aws-cdk-app

Usage

To generate a workspace run:

npx create-aws-cdk-app nx-aws-cdk-workspace -i infra -l lambda

First argument is a workspace name, so after generation completed you can navigate to the nx-aws-cdk-workspace folder.

Local mode

By default cdk executor will deploy all changes to localstack environment. You need to have docker installed in order to use this mode.

npx nx cdk infra diff
npx nx cdk infra deploy --all

After deployment you can view your resources using awslocal cli:

awslocal lambda list-functions
awslocal lambda invoke --function-name <functionName> '/dev/stdout'

After exploring you can destroy your resources by running npx nx cdk infra destroy --all command.

AWS mode

In order to use cdk executor for aws deployment you need to have configured aws credentials. You can achieve this by configuring awscli. And you need to provide --env <envName> flag to cdk executor. Environment name can be any string except local because it is reserved for localstack environment.

npx nx cdk infra diff --env dev
npx nx cdk infra deploy --env dev --all

After deployment you can explore your resources:

aws lambda list-functions
aws lambda invoke --function-name <functionName> '/dev/stdout'
// Run to clean up your resources
npx nx cdk infra destroy --all --env dev

Lambda application generation

You can generate new lambda application by running withing you workspace:

// Optionally you can run deploy in watch mode so it will be deployed instantly after generation and any cahnges. You need to have a separate terminal window for this command.
npx nx cdk infra deploy --env dev --watch
npx nx g aws-lambda lambda

Available options

name type default required alias description
infraAppName string infra false i Name of cdk application.
lambdaAppName string false l Name of lambda application. If not provided lambda application will not be generated during workspace creationg.
unitTestRunner string jest false u Will add corresponing unit test executors and files. Available options jest, none.

For detailed documentation navigate to the nx-aws-cdk package. It will has documentation for lambda and cdk applications generators and cdk executor.

Maintainers

@KozelAnatoliy

License

MIT © 2023 Anatoli Kozel

Package Sidebar

Install

npm i create-aws-cdk-app

Weekly Downloads

56

Version

1.4.2

License

MIT

Unpacked Size

8.44 kB

Total Files

5

Last publish

Collaborators

  • tolis_propolis