Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@berenddeboer/nx-aws-cdk

berenddeboer2kMIT3.0.0-alpha9TypeScript support: included

Nx self-inferring plugin for AWS CDK stacks

nx, aws-cdk, monorepo, aws cdk, Node

readme

standard-readme compliant @berenddeboer/nx-aws-cdk Typescript LICENSE npm version Downloads


@berenddeboer/nx-aws-cdk

A self-inferring Nx plugin for developing aws-cdk applications.

Table of Contents

Install

# npm
npm install --save-dev @berenddeboer/nx-aws-cdk

# pnpm
pnpm i --save-dev @berenddeboer/nx-aws-cdk

# yarn
yarn add --dev @berenddeboer/nx-aws-cdk

Usage

Plugin

This package uses inferred targets (tasks). Any project with a cdk.json in its root will create the appropriate cdk targets for that project.

You can configure the default target names in the plugin:

{
  "plugin": "@berenddeboer/nx-aws-cdk/plugin",
  "options": {
    "cdkTargetName": "cdk",
    "synthTargetName": "synth",
    "deployTargetName": "deploy",
    "diffTargetName": "diff",
    "rollbackTargetName": "rollback",
    "watchTargetName": "watch",
    "destroyTargetName": "destroy"
  }
},

Remove a target if you do not want it auto-generated.

There's no need to use the executor anymore, but you can still use it for non-inferred targets.

Use the cdk target to run any cdk command easily:

npx nx run my-stack:cdk import ...

Generating a CDK application

To generate an AWS CDK v2 Application:

npx nx generate @berenddeboer/nx-aws-cdk:application --directory=stacks/cdk-app --name=cdk-app

Currently (alpha 3 versions): do not specify a unit test runner or eslint. This crashes nx for as yet unknown reasons.

You can customize it further by passing these options:

nx generate @berenddeboer/nx-aws-cdk:application [name] [options,...]

Options:
  --tags                     Add tags to the project (used for linting)
  --skipFormat               Skip formatting files
  --unitTestRunner           Adds the specified unit test runner (default: jest)
  --linter                   The tool to use for running lint checks. (default: eslint)
  --setParserOptionsProject  Whether or not to configure the ESLint "parserOptions.project" option. We do not do this by default for lint performance reasons.
  --dryRun                   Runs through and reports activity without writing to disk.
  --skip-nx-cache            Skip the use of Nx cache.
  --help                     Show available options for project target.

Targets

Generated applications expose several functions to the CLI that allow users to deploy, destroy and so on.

nx deploy myApp
nx destroy myApp

We infer the most common cdk commands. Use the executor to have access to all CDK commands.

Contributing

See the contributing file!

PRs accepted.

If editing the README, please conform to the standard-readme specification.

License

This project is MIT licensed.