Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run my CDK app?

I created and built a new CDK project:

mkdir myproj
cd myproj
cdk init --language typescript
npm run build

If I try to run the resulting javascript, I see the following:

PS C:\repos\myproj> node .\bin\myproj.js
CloudExecutable/1.0

Usage:
  C:\repos\myproj\bin\myproj.js REQUEST

REQUEST is a JSON-encoded request object.

What is the right way to run my app?

like image 523
Matthew Avatar asked Jul 31 '18 14:07

Matthew


1 Answers

You don't need to run your CDK programs directly, but rather use the CDK Toolkit instead.

To synthesize an AWS CloudFormation from your app:

cdk synth --app "node .\bin\myproj.js"

To avoid re-typing the --app switch every time, you can setup a cdk.json file with:

{ "app": "node .\app\myproj.js" }

Note: A default cdk.json is created by cdk init, so you should already see it under C:\repos\myproj.

You can also use the toolkit to deploy your app into an AWS environment:

cdk deploy

Or list all the stacks in your app:

cdk ls
like image 136
Elad Ben-Israel Avatar answered Sep 28 '22 08:09

Elad Ben-Israel