DEV Community

Ivan Bliskavka
Ivan Bliskavka

Posted on • Edited on • Originally published at bliskavka.com

2

CDK package.json Scripts

I found the following package.json scripts very convenient when managing a complex CDK app. The key is the -- operator, which allows us to append additional parameters to a script.

{
  "scripts": {
    "build": "tsc --noEmit",
    "cdk": "npm run build && cdk",
    "cdk:pipeline": "npm run build && cdk --app 'npx ts-node --prefer-ts-exts bin/pipeline.ts'",
    "test": "jest",
    "diff": "npm run cdk -- diff",
    "synth": "npm run cdk -- synth --quiet",
    "deploy": "npm run cdk -- deploy --all --require-approval never",
    "deploy:pipeline": "npm run cdk:pipeline -- deploy --all --require-approval never"
  }
}
Enter fullscreen mode Exit fullscreen mode

This configuration allows us to create convenient scripts like deploy/diff/synth, but we still have the ability to pass in additional parameters like:

npm run deploy -- --no-rollback --profile default

I can also define multiple entry points

  • cdk: Interact with the stack directly.
  • cdk:pipeline: Deploy a CDK Pipeline which is able patch the CDK app when new changes are pushed.

A pipeline execution can be slow, so being able to circumvent the pipeline in a dev/sandbox environment is extremely useful.

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay