DEV Community

Cover image for Deploy your first app on AWS with AWS CDK - Part 1
Veliswa_Boya πŸ‡ΏπŸ‡¦ for AWS

Posted on • Updated on

Deploy your first app on AWS with AWS CDK - Part 1

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 (building blocks of AWS CDK applications).
Constructs are composed into Stacks (which are ultimately deployed as CloudFormation Stacks) and Apps 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 (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 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

, else you will encounter errors when attempting to synthesize your CloudFormation template as seen in example below:
image

A successful cdk synth command will output the CloudFormation template as seen below:
image

A successful cdk deploy will deploy your CloudFormation template into your AWS account - below is what you will see in your account:

image

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

image
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:

Top comments (0)