Deploy your first app on AWS with AWS CDK - Part 1
Tags: aws, awscdk, iac, beginners
Published: 2021-03-08 11:58:01

AWS Cloud Development Kit (AWS CDK), is an open source software development framework that lets you as a developers define cloud application resources using familiar programming languages, so you do not have to learn a new domain-specific language (e.g. YAML or JSON). The AWS CDK lets developers manage those resources in the same way that they manage their application code, ensuring visibility, reproducibility, and repeatability, and it is part of how modern applications treat their infrastructure as code.

AWS CDK supports TypeScript, JavaScript, Python, Java and C# as the programming languages that can be used to define reusable cloud application components called [Constructs](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html)  (building blocks of AWS CDK applications). 
Constructs are composed into [Stacks](https://docs.aws.amazon.com/cdk/latest/guide/stacks.html) (which are ultimately deployed as CloudFormation Stacks) and [Apps](https://docs.aws.amazon.com/cdk/latest/guide/apps.html) which produce the AWS CloudFormation template that has been defined by the Stack.

AWS CDK Apps define your infrastructure as code; in order to produce (synthesize) the CloudFormation template for each stack the apps need to be executed via the **cdk synth** command, and the template deployed into your AWS account via the **cdk deploy** command.

Whether you are already familiar with AWS CDK already or [AWS CloudFormation](https://aws.amazon.com/cloudformation/) (CDK produces a CloudFormation template which then deploys your app into your AWS account) - or not - there are resources that exist to help you deploy your first app using AWS CDK.

In this post, I used one of those helpful resources - I used the [CDK Workshop](https://cdkworkshop.com/30-python/20-create-project.html) to demonstrate how to synthesize a CloudFormation Template from a CDK app and deploy that to an AWS account - I chose Python as my programming language of choice.

***The AWS CDK Workshop***

The workshop contains details on all the pre-requisites that you will need in order to successfully deploy this first app so I will not repeat those here; let me however mention that this app deploys the following AWS resources for you:
  - SQS Queue (sqs.Queue)
  - SNS Topic (sns.Topic)
  - Subscribes the queue to receive any messages published to the 
    topic (topic.add_subscription)

Ensure to install the SQS, SNS, SNS_Subscriptions packages from the AWS Construct Library as per example below:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ogm95nlxq7lwarajto39.png)
 
 , else you will encounter errors when attempting to synthesize your CloudFormation template as seen in example below:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xztfagufljeos1s37twl.png)
 
A successful __cdk synth__ command will output the CloudFormation template as seen below:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtfsta2vfi90ktvcqirw.png)
 
A successful __cdk deploy__ will deploy your CloudFormation template into your AWS account - below is what you will see in your account:

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e34fjrksqt0uwxker8t8.png)

 Expand the stack and view **Resources** and this is what you will 
   see: 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u325sn9bmd0ruy6ogydu.png)
Each of the resources aligns to the constructs defined as part of the stack - inside the app - as detailed at the beginning of this article.

And that's it - you successfully deployed a CloudFormation template that provisioned your resources as defined in your AWS CDK app.

***Conclusion***

AWS CDK Documentation talks about "dipping your toe in the water" of CDK and I found this workshop to be a great way of doing exactly this. 
Follow along as I did, let me know if you ended up provisioning completely different resources to the ones I provisioned.

***References:*** 
- [CDK Workshop](https://cdkworkshop.com/)
- [AWS Cloud Development Kit Documentation](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#getting_started_prerequisites)
- <span>Cover image by <a href="https://unsplash.com/@galen_crout?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Galen Crout</a> on <a href="https://unsplash.com/collections/1399960/infrastructure?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>