AWS CDK (Infrastructure As Code)
Different than SDK:
- CDK is infrastructureas code to create AWS infrastructure.
- SDK is to connect to other aws services on your code
- Define your cloud infrastructure using programming language. Similar to CloudFormation
Javascript
,typescript
,python
,java
,.net
- Note: the code must be compilable for this to work
- The code is then compiled into CloudFormation template (JSON/Yaml)
- Useful when you want type-safe.
Getting started
Run this in an empty folder to initialise the project
cdk init --language javascript
Once done, do this to create a cloud formation template on AWS
cdk bootstrap
(Optional) to see the output of cloudformation template
cdk synth
If happy, we can then deploy the CloudFormation template
cdk deploy
If we want to destroy the stack
cdk destroy