TomSpencerLondon / AWS-CDK-Practice

Practice with AWS CDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to your CDK Java project!

This is a blank project for CDK development with Java.

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.

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!

Install CDK

npm install -g aws-cdk cdk init app --language java

CDK Java Example

This is an example of a CDK program written in Java.

Building

To build this app, run mvn compile. This will download the required dependencies to compile the Java code.

You can use your IDE to write code and unit tests, but you will need to use the CDK toolkit if you wish to synthesize/deploy stacks.

CDK Toolkit

The cdk.json file in the root of this repository includes instructions for the CDK toolkit on how to execute this program.

Specifically, it will tell the toolkit to use the mvn exec:java command as the entry point of your application. After changing your Java code, you will be able to run the CDK toolkit commands as usual (Maven will recompile as needed):

$ cdk ls
<list all stacks in this program>

$ cdk synth
<cloudformation template>

$ cdk bootstrap

$ cdk deploy
<deploy stack to your account>

$ cdk diff
<diff against deployed stack>

$ cdk destroy
cdk ls shows cdk-lambda-cron-example

I destroy the stack with those commands

cdk destroy cdk-lambda-cron-example

About

Practice with AWS CDK


Languages

Language:Java 100.0%