
Q-Bits: Getting Started with CDK: Building Your First Infrastructure as Code Application using Amazon Q Developer
Follow along as Amazon Q Developer helps you build and understand your first CDK application from scratch
Amritha
Amazon Employee
Published May 5, 2025
Last Modified May 6, 2025
Welcome to another installment of Q-Bits, our regular series showcasing cool ways Amazon employees are leveraging Amazon Q Developer. Today, we're diving into how Q Developer can assist with creating your first CDK application.
Infrastructure as Code (IaC) has revolutionized how we manage cloud resources, and AWS CDK (Cloud Development Kit) stands at the forefront of this revolution. If you're taking your first steps into IaC, CDK offers a familiar approach using programming languages like TypeScript, Python, Java or golang instead of writing JSON or YAML templates.
Getting started with CDK might seem daunting at first, but with Amazon Q Developer as your guide, you'll be creating your first CDK application in no time. Before we begin our hands-on journey, make sure you have:
- An AWS account with appropriate permissions
- A code editor of your choice (I will be using VS Code in this blog)
- AWS CLI
In this guide, we'll use Amazon Q Developer to:
- Set up a new CDK project
- Understand the basic project structure
- Create our first infrastructure component
- Deploy our stack to AWS
Let's start our CDK journey by asking Amazon Q Developer for detailed guidance:
My Amazon Q Developer Conversation in Q chat in VS Code:
"I am new to CDK and would like to create my first CDK application. I prefer to work with TypeScript. Could you provide a detailed, step-by-step guide on how to create a CDK application?”
Amazon Q developer response:
Amazon Q Developer immediately provided a comprehensive guide, which we'll break down step by step below:
Step 1: Amazon Q developer guides by asking us to install the prerequisites of Node.js and aws-cdk

Step 2: Install and configure AWS CLI

Step 3: Initialize Your CDK Project for Typescript by running ‘cdk init app --language typescript’. We are going to use Typescript, but you can use any supported language.

Step 4: When you initialize a new CDK project with
cdk init app --language typescript
, it creates a standardized directory structure. Amazon Q developer helps in understanding the Project Structure.
Step 5: Install dependencies: The initialization process installs basic dependencies, but if you add any other dependencies, you will need to run npm install to install the dependencies.

Step 6: Bootstrap AWS Environment: Before deploying our first CDK app, we need to bootstrap our AWS environment. Bootstrapping creates resources in the AWS account that CDK needs for deployment, such as an S3 bucket for storing assets.

Step 7: Amazon Q developer helps in creating a simple cdk stack with a S3 bucket resource.

Step 8: Build the project by compiling the TypeScript code using ‘npm run build’ command.

Step 9: cdk synth (synthesis) is a CDK command that converts your CDK code into CloudFormation templates. run the ‘cdk synth’ command [AS1] to synthesize the cdk code to a CloudFormation template.

Step 10: Review Changes Before Deployment by running ‘cdk diff’ command[AS2] . cdk diff compares the current state of your CDK app with the deployed stack in AWS, showing what changes would be applied if you were to deploy the current version.

Step 11: Deploy the CDK App by running ‘cdk deploy’ command.

Step 12: verify the deployment by checking the AWS console

Step 13: Making Changes to our Infrastructure: to make changes, update the code, add, remove any resources, then build and deploy. Basically, you will be repeating steps 7-12.

Step 14: If you need to clean up the resources, you can run ‘cdk destroy’ command, which will delete all the created resources.

Amazon Q developer also suggested the following best practices and troubleshooting tips:

AWS CDK represents a powerful approach to Infrastructure as Code, and with Amazon Q Developer as your guide, the learning curve becomes much more manageable. We've seen how Amazon Q Developer can help you:
- Set up your development environment
- Create and understand CDK project structure
- Deploy your first infrastructure component
- Follow best practices from the start
To continue your CDK journey, consider:
- Exploring more complex CDK patterns
- Learning about CDK constructs
- Building multi-stack applications
- Contributing to the CDK community
With Amazon Q Developer as your coding companion, you're well-equipped to build robust, scalable infrastructure using CDK. Happy coding!
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.