AWS CDK Reference Link
AWS Construct Library Reference Link
Make sure you have latest version of node installed.
npm install -g aws-cdk
Check CDK version
cdk --version
We will use Java Language in this project.
mkdir <DIR_NAME> && cd <DIR_NAME>
cdk init app --language java
There is a simple way to get a starter template for your project i.e. Bootstrapping
You need your account id and your region where CloudFormation will setup it's stack
aws --profile <PROFILE_NAME> --region <REGION_NAME> sts get-caller-identity
cdk bootstrap aws://<ACCOUNT_ID>/<REGION_NAME>
You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (AwsCdkStack
)
which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic.
The cdk.json
file tells the CDK Toolkit how to execute your app.
It is a Maven based project, so you can open this project with any Maven compatible Java IDE to build and run tests.
mvn package
compile and run testscdk ls
list all stacks in the appcdk synth
emits the synthesized CloudFormation templatecdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk docs
open CDK documentation
Enjoy!
<DIR_NAME>App.java:
The entrypoint for the CDK application it will load the stack defined in here.<DIR_NAME>Stack.java:
CDK's application main stack is defined here.cdk.json:
tells the toolkit how to run your app. In our case it will be "mvn -q exec:java"pom.xml:
is the Maven project file. It is an xml file and contains information on build properties, dependencies, and app information.