cdk init

Create project directory #

Create an empty directory on your system:

mkdir cdk-workshop && cd cdk-workshop

cdk init #

We will use cdk init to create a new Java CDK project:

cdk init sample-app --language java

Output should look like this (you can safely ignore warnings about initialization of a git repository, this probably means you don’t have git installed, which is fine for this workshop):

Applying project template sample-app for java
# Welcome to your CDK Java project!

You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`CdkWorkshopStack`)
which contains an Amazon SNS topic that is subscribed to an Amazon SQS queue.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

It is a [Maven](https://maven.apache.org/) based project, so you can open this project with any Maven compatible Java IDE to build and run tests.

## Tutorial
See [this useful workshop](https://cdkworkshop.com/50-java.html) on working with the AWS CDK for Java projects.

## Useful commands

 * `mvn package`     compile and run tests
 * `cdk ls`          list all stacks in the app
 * `cdk synth`       emits the synthesized CloudFormation template
 * `cdk deploy`      deploy this stack to your default AWS account/region
 * `cdk diff`        compare deployed stack with current state
 * `cdk docs`        open CDK documentation

Enjoy!

Initializing a new git repository...
Executing 'mvn package'

✅ All done!

As you can see, it shows us a bunch of useful commands to get us started.

See Also #

We use analytics to make this content better, but only with your permission.

More information