Chapter 1. Getting Started with CDK

This book is project driven. We want you to get hands on and learn by building. We start by introducing the project that you will be building throughout the book. After introducing the project we will get you all set up with your development environment and prerequisites so that we can begin building in Chapter 2. In this chapter we will cover just a bit more background so that we can hit the keyboard right away with all the subsequent chapters.

We want to give a friendly warning that if you are brand new to cloud development, IT administration, or AWS this chapter may feel challenging. If you have some experience this may be a bit more accessible, but some concepts may still be new. In designing the book we made conscious decisions to avoid the “easy route” if it was going to instill bad habits for security and cost optimization. This means the learning curve may feel a bit steep in this first chapter, but in the long-run you will be a stronger cloud developer for it. With that said please do provide feedback where we can make the directions simpler or more clear, we are always looking for ways to make these topics more accessible while still providing expert level knowledge and skills.

Take a deep breath and let’s go step by step. In this chapter you will learn:

  • How to set up your AWS Account

  • How to set up the AWS Command Line Interface (CLI)

  • How to set up your development environment

  • How to set your first project

To get started you will need:

  • A computer running MacOS, Linux, or Windows

  • An internet connection

What you will build

There are two major projects in this book, each consisting of several smaller projects, or microservices. The first project will be one we do together. We will call this Project 1, or The Shared Project. This project will be your own version of an application unofficially named Home Energy Coach, but you can call it something different as you make it your own.

Each chapter will focus on a step by step tutorial where we teach you CDK concepts while building new features into our application. By the start of the penultimate chapter you will have a full application that will be mostly the same as any other person who finishes this book. In the final chapter you will have an opportunity to select your own use-case, design, build, and deploy an application that is unique to you. This is Project 2 — the Portfolio Project. Think of the first project, or the shared project, as preparation for your own creative endeavor — building a solution to a problem you are familiar with or would like to explore.

In this section we will introduce you to the Shared Project, which will occupy every chapter of this book except for the last. Just keep in mind that everything you are learning is meant to prepare you for the exciting task of building your own project with AWS CDK. Don’t worry, we will guide you through the whole process and even share some starter case studies if you need some ideas to get started. Read on for all the details of our shared project. We will revisit project 2 (aka your Portfolio Project) in the final chapters.

Note

We will make occasional references to Project 2, the Portfolio Project, throughout the book. As you are learning and building and following directions we want you to be constantly asking yourself “how can I use this in a different way for my own project?”

Project 1 - The Shared Project

Throughout this book you will be asked to take on the role of lead cloud architect, developer, and technical project manager for a cloud-native software solution. You are tasked with building an open-source software platform to help individuals track, analyze, and understand their home energy usage. This application needs to be relevant to homeowners, renters, or anyone else who uses electricity in the place they call home. This platform will be deployed as Infrastructure as Code on AWS and built using AWS CDK in Typescript, with application logic written in Javascript. The application you build will allow users to upload home energy use data in csv format, and as utility bill image files.

The application will record energy use over time, display it in simple graphics on a web page, and utilize a chatbot interface, search, natural language processing, and generative AI to make energy optimization recommendations based on the user’s defined energy goals. This solution will combine elements of serverless API development, web application development, AI/ML, DevOps, and data analytics. You will also get to interact with free external APIs for foundational large language models and real-time carbon emissions measurement. The project will be deployed via a GitHub actions pipeline, and will utilize unit, infrastructure, integration, and end to end functional testing. The project will allow you to make personalized customizations by following the extension activities with each chapter.

If you’re wondering “but is this really how someone would deploy a real application on AWS” the answer is emphatically YES. We wrote this book to be the guide we never had when developing real AWS solutions used in industries and enterprises. This is an accelerated introduction that prepares you to build real applications for real businesses. Have fun with it. We had a lot of fun building it.

By the end book you will have a portfolio-ready project that you can maintain on your public GitHub page to demonstrate your cloud development skills. The project will also prepare you with all of the necessary skills and concepts to build your own cloud-native CDK application in the culminating capstone project chapter at the end of this book. In the next section you will learn about the technical details and AWS services that will be used in the project.

Figure 1-1 shows the Home Energy Coach application that we will build incrementally. Don’t worry if this doesn’t make sense right now. We will go step by step in the coming chapters.

Home Energy Coach Application Architecture
Figure 1-1. This is the architecture for the final project we are building. Each chapter will add features to our application.
Electric Utility Usage Data

Raw data landing zone for electric utility usage .csv files.

Custom S3 Raw Data Bucket

Raw data landing zone for electric utility usage .csv files.

Amazon Eventbridge Data Upload Event Trigger

trigger for data transformation and notifications.

Simple Notification Service

email and optional SMS (test message) notifications about data upload.

Custom Lambda Function

transforms raw data into a format that can be used for calculations.

Amazon Eventbridge

trigger for energy usage calculator.

Custom Lambda Function

calculates energy usage.

Custom DynamoDB Table

stores calculated energy usage for transactional access.

Custom S3 Bucket

stores calculated energy usage for analytical access.

Simple Notification Service

email and optional SMS (test message) notifications about calculated energy usage.

REST API

provides access to calculated energy usage data.

Level 3 Generative AI Chatbot Construct

combines search, chatbot, and generative AI to provide summaries and recommendations about energy usage.

AWS Amplify Web Application

front-end interface for energy coach application.

Project 2 - The Portfolio Project

The second project in this book is your own. We will provide some case studies and ideas to get you started, but ultimately you will be responsible for designing, building, and deploying your own cloud-native application using AWS CDK. This project will be an opportunity to demonstrate your creativity, interests, and expertise. We invite you to take what you learn in Project 1 and extend, remix, and rethink it in a new context. In the final chapter we will guide you through the process of coming up with an idea, understanding your users and what they need, and building it. We encourage you to begin thinking about your project now, and to keep it in mind as you work through the rest of the book.

Prepare your learning environment

Throughout the book we will refer to a project code repository hosted on GitHub called hands-on-aws-cdk-book-projects. We recommend opening this project repository and starring and bookmarking it on GitHub. By the end of this book you may even feel inspired to contribute to the project repository. More on that later. For now you will want to open the repository so that you can refer to it throughout the book. This repository includes synthetic datasets that you will need to use in the project and includes completed versions of each project with extensive in-line code comments.

The project repository can be found here: CDK Book

The project repository has the following directory structure:

Example 1-1. Project Repostitory Directory Structure
hands-on-aws-cdk-book-projects
├── app   └── home-energy-coach <-- this is where the projects will be   └── resources <-- this includes setup resources from chapter 1
├── synthetic-data <-- this contains the synthetic data you will use
├── CONTRIBUTING.md <-- guide for contributors (could be you!)
├── README.md <-- readme for the repository with links to all chapter projects
└── .gitignore <-- tells git which files to ignore

Each chapter has a corresponding git branch. The default branch (main) has the completed project that you will build by the end of the book. Each branch from there is named for the chapter: chapter-1, chapter-2 etc. We recommend viewing each branch along with the chapter, as the code changes throughout the project, but many items stay similar.

Project repository Github Branches
Figure 1-2. This is the architecture for the final project we are building. Each chapter will add features to our application.

You can use this a few different ways:

  1. Keep the project repository open at all times and refer back to it regularly with each new step of the projects. Use the project as an exemplar or a way to get unstuck if you’re not sure. Use this approach if you like to have a strong example to guide your work every step of the way.

  2. Keep the project repository bookmarked and open it at the end of each chapter to check your work against an example. Use this approach if you like to work with some ambiguity and prefer to use your own resources and check your work only at the end.

You will need the project repository for datasets, but it is not required for any other parts of the book.

Set up your cloud development environment

To get started you will learn to set up your cloud development environment with VS Code, Git, and AWS CLI so that you can begin building cloud infrastructure. After you get set up, you can build your first project! This is the Cloud Development Kit (CDK) equivilant to “Hello World!”

You will use the environement you set up here to build, manage, and deploy CDK projects in the rest of this book.

Set up your AWS account

Setting up an AWS (Amazon Web Services) account and generating access keys is a crucial step for developers who plan to use AWS services for cloud development. AWS provides a wide range of cloud computing services, including computing power, storage, databases, networking, and more, that can be used to build and deploy applications.

Here’s a brief overview of how to set up an AWS account and generate access keys for development:

  1. Sign up for an AWS Account: Visit the AWS website and click on the “Create an AWS Account” button to start the sign-up process. Follow the instructions to provide the required information, such as email address, password, and payment details.

  2. Provide Payment Information: AWS requires a valid payment method, such as a credit card, to verify your identity during the account setup process. You will not be charged unless you use paid services beyond the free tier. Don’t worry. We will show you how to set up a budget to avoid surprise bills.

  3. Complete Identity Verification: As part of the account setup process, AWS may require additional identity verification, which can be done through phone verification or uploading identification documents.

Great! Now you have set up your AWS account with what is known as your root user. Next we will set up AWS Budget to avoid surprise bills. Soon you will log out of this user and NEVER EVER EVER log back in to do development work. We will show you how to set up an admin user for development work in the upcoming section. But first, budgets.

Set up AWS Budgets

When starting out with AWS, it’s easy to unintentionally go outside the boundaries of the Free Tier and get charged more than expected. To avoid surprise bills, set up budgets to keep your usage in check.

Here’s how to set budgets in AWS:

  1. Log in to your AWS account

  2. Use the top search bar to search for “Budgets” and select the Billing and Cost Management service

  3. On the left sidebar, click Budgets under Budgets and Planning. You will likely need to activate cost explorer to activate budgets, so click the link to do so.

  4. Select “Create budget” and “Monthly cost budget”

Create a new budget
Figure 1-3. Budget setup
  1. Select “Use a template (simplified)” and “Monthly cost budget”

  2. Give your budget a name. Something like “cdk-learning-budget”

  3. Set the Budgeted amount, such as $10. For this project your costs will depend mostly on how much you use your app. If you set a budget of $50/month this should be a good starting point. Most of the services we use will be within free tier, so you can also set your budget as $0. This will alert you before going over Free Tier.

Budget creation
Figure 1-4. Budget creation
  1. Enter your email so that you receive email alerts.

  2. Review the budget settings then select “Create budget”

Warning

Seriously do not skip this step. There are two types of Cloud developer (well, many more than two, but bear with us…​): 1) The kind who use budgets and 2) The kind who have accidentally spent some enormous sum of money on misconfigured resources when they were first learning, costing themselves or their employers a ton of money.

Be the first kind, not the second. Some lessons stick better when you learn them the hard way. Some are just embarrassing. Just trust us. We have both learned the hard way so that you don’t have to.

Now your AWS account has spending guard rails! The dashboard will track your usage across services and alert you as the budget limit nears. You can explore AWS freely without worrying about surprise overages. Next up you will create your Admin user using AWS Identity and Access Management (IAM). This is the user you will log in with to carry out administrative tasks. You will never log in with your root user again.

Create an Admin IAM user

When you first create an AWS account, you sign in with root user credentials. But it’s risky to use the powerful root account for everyday work! Follow these steps to set up an admin IAM user instead:

  1. To deploy a simple one-click cloudformation script that creates a secure IAM admin user and cdk developer user for you go to http://www.github.com/hands-on-aws-cdk/chapter-1/iam.md#automatic-deployment and follow the one-click deployment process.

  2. To follow all steps and manually create your IAM user credentials (this is the best way to learn the process) follow this link and follow all instructions closely: http://www.github.com/hands-on-aws-cdk/chapter-1/iam.md#manual-deployment

Sign in and generate keys for your CDK developer user

You are going to enable console access and access keys. This is the user you will assume for all development for the rest of this book.

  1. Select Enable console access and follow all instructions to set up and enable MFA for console access.

  2. Select Create access key

  3. Under Use case select Command Line Interface (CLI) and select the checkbox indicating that you understand the other recommended methods and choose this one. Click Next

  4. Under description tag add a brief description like <your-initials>CdkDeveloperCliKeys<date><year>

  5. Select Create keys. Save the csv or copy/paste the access keys because you will need them for the next step.

Tip

DO save the keys somewhere temporary so you can use them in a few minutes. DO NOT save the keys permanently on your machine. You should permanently delete them as soon as you confirm that they are working locally.

Now your user is ready for CDK deployment! Its keys authenticate your cdk terminal sessions.

With this limited-access user, you can develop safely in AWS. In the next step you will set these keys up for accessing the AWS CLI.

Note

Wow! That was a long and tedious process, right? We know. It’s like that for a reason. Security and identity and access management require friction. The meticulously detailed process of setting up IAM role, policy, user, access keys is what allows us to maintain PoLP effectively. We thought hard about making this “easier” for our readers so that you could “focus on development”. Through experience we have seen the dangers of outsourcing IAM setup and management. Any strong cloud developer needs to be familiar with IAM, and comfortable troubleshooting when permissions aren’t quite right. If you don’t know IAM you will have a big gap in your cloud development and security skillset, so this is a great time to get familiar through practice. To read more about setting up IAM review the official AWS IAM user guide.

With your limited-privilege IAM user set up, you can develop safely knowing exactly what CDK access is permitted. As a final step you will set up the AWS Command Line Interface (CLI) so that you can beging building on your local machine.

Set up the AWS CLI

In this book we will set up the AWS CLI to store our credentials locally in a profile, and access AWS from the command line. This step assumes some knowledge of your operating system’s command line.

Here’s a brief overview of how to set up the AWS CLI and begin deploying AWS resources:

  1. Install AWS CLI: The AWS CLI can be installed on various operating systems, including Windows, macOS, and Linux. Follow the AWS documentation for instructions on how to install the AWS CLI on your preferred operating system. The current edition of this book uses AWS CLIv2, so even if you have the AWS CLI installed it is important to ensure you have the latest version. You can check by running aws --version in your terminal. This should return aws-cli/2.13.13 or greater.

  2. Configure AWS CLI: After installing the AWS CLI, you need to configure it with your AWS account credentials. This includes providing your AWS Access Key ID, Secret Access Key, default region, and default output format. You can configure the AWS CLI using the aws configure command and following the prompts, or by manually editing the AWS CLI configuration files.

Try it out now using the Key and Secret from the previous step. Follow the prompts to save your developer keys to your AWS configuration file locally:

aws configure

You should see prompts that look like this:

AWS Access Key ID [None]: <insert your key ID when prompted>
AWS Secret Access Key [None]: <insert your secret key when prompted>
Default region name [None]: <insert us-east-2 or another region>
Default output format [None]: <leave this as black to select default>
Tip

If you are not sure which region to use, try “us-east-2” (located in Ohio). AWS divides the world into regions which are nodes on the AWS network. There are four regions located in the United States and also regions across the globe. You generally want to chose a region that is close to where you are working to reduce latency but there are also times when you might want to work in another region based on the project you are developing.

Verify that everything is set up by checking your assumed identity:

aws sts get-caller-identity
# this should print your AWS account ID to the console

Once the AWS CLI is configured, you can verify the setup by running a simple AWS CLI command, such as “aws s3 ls” to list the objects in an S3 bucket. If the command executes successfully and returns the expected results, it indicates that your AWS CLI setup is correct.

With the AWS CLI set up, you can start deploying AWS resources using the AWS CLI commands. AWS CLI provides a wide range of commands to manage various AWS services, such as EC2 instances, S3 buckets, CloudFormation stacks, and more. You can use these commands to create, configure, update, and delete AWS resources as needed for your development and deployment workflows.

One of the key benefits of using the AWS CLI is the ability to automate AWS operations using scripts or other automation tools. You can write scripts or use tools like AWS CloudFormation, AWS SDKs, or other infrastructure-as-code frameworks to automate the deployment and management of AWS resources, making it efficient and repeatable. In our case we will do all of these things, but mostly wrapped in CDK.

Set up your local development environment

Developers need a place to develop. One widely used Integrated Development Environment (IDE) for CDK development is Visual Studio Code (VSCode), which provides a rich set of features for code editing, debugging, and version control.

Note

There are lots of IDEs to choose from. We use VS Code throughout the book but you can use whichever IDE you prefer. Some other common IDEs are GitHub Codespaces and AWS Cloud9.

Set up Visual Studio Code

To set up VSCode for CDK development follow these steps:

  1. Install VSCode: Download and install Visual Studio Code from the official website (https://code.visualstudio.com/) for your operating system.

  2. Install CDK Extensions: VSCode has several extensions specifically designed for CDK development, such as “AWS Toolkit” and “CDK Explorer”. Install these extensions from the VSCode Extensions Marketplace to enhance your CDK development experience.

  3. Install Node.js: CDK is built on Node.js, so make sure you have Node.js installed on your development machine. You can download and install Node.js from the official website (https://nodejs.org/). We also cover this in the next section.

  4. Install CDK Toolkit: CDK Toolkit is a command-line interface (CLI) that is used to interact with CDK applications. Install it globally on your machine using npm (Node Package Manager) by running the command: npm install -g aws-cdk.

With these steps, you can set up VSCode as an IDE for CDK development and start building cloud applications using the power of Infrastructure as Code (IAC) with CDK.

Set up Git and GitHub

Setting up Git and GitHub is an essential step for version control and collaborative software development. Git is a distributed version control system that allows developers to track changes, collaborate, and manage source code efficiently, while GitHub is a popular web-based hosting service for Git repositories, providing a platform for collaboration and sharing of code among team members.

Note

In this book we use GitHub but you could use any Git repo that you like. Other popular Git repos include GitLab, BitBucket, and AWS CodeCommit.

Git can be installed on various operating systems, including Windows, macOS, and Linux. Follow the Git documentation for instructions on how to install Git on your preferred operating system. You can find an instructive guide for setting up git locally at https://github.com/git-guides/install-git

After installing Git, you need to configure it with your name and email address, which will be associated with your Git commits. You can configure Git using the git config command and providing your name and email address as arguments.

If you don’t have a GitHub account, sign up for a free account on the GitHub website. You will need a GitHub account to host and share your Git repositories on GitHub. We will encourage you to use this throughout your project. Git-based version control is an important part of any cloud developer’s workflows.

Setting up Git and GitHub simplifies version control and collaboration. Even if you are a one-person development team, using Git allows up to track changes and share code easily. It streamlines the development workflow and we will use it throughout this book.

Note

There are lots of tutorials about Git if you want to dive deeper. We like the tutorial from Software Carpentry.

Install prerequisite packages and software

We are almost ready to start building. The next section guides you through installation of prerequisite software and packages. The great news is that you only have to do this once on a given machine and then you can build lots of things whenever you want.

Install Node and NPM

Make sure you have Node and NPM running on your machine. We installed them in previous steps, but it’s always good to double check:

node --version
npm --version

Both commands should produce an output stating the version of the package.

We will be building all of our applications using Typescript, which will be installed by default as a dependency for the CDK. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It adds optional static typing, classes, interfaces, and other features to standard JavaScript syntax for larger scale development. TypeScript adds type safety and scalability to JavaScript, making it well-suited for infrastructure as code development.

Its optional typing provides guardrails when coding - it catches errors during compilation that would otherwise cause runtime crashes. This helps catch infrastructure bugs before provisioning. The class-based object orientation also helps organize all the infrastructure constructs needed for IaC solutions like CDK. TypeScript provides guardrails and organization on top of JavaScript for more robust IaC development.

Install CDK

Now that you have all the CDK prerequisites the final step is to install the CDK command line interface, and the cdk-lib core library of constructs.

Start by installing the aws-cdk CLI globally on your machine. This was you can use it when creating new projects. It will help to scaffold many processing of building with CDK.

npm install -g aws-cdk
cdk --version

Next install the aws-cdk-lib core library. This consists of the core L1, L2, and L3 constructs contributed by AWS and the open source community, and maintained by the AWS CDK team and core contributors.

npm install aws-cdk-lib

Now that you have installed all of the prerequisite sofware you are ready to start building. Before we build it is essential that you understand the L1, L2, and L3 CDK construct categories. In the next section we will explore L1, L2, and L3 constructs with a simple example. Don’t worry if the difference isn’t immediately clear to you. You are about to get a lot of practice with these topics.

Infrastructure as Code and automation

In the context of Infrastructure as Code (IaC), automation can greatly simplify and accelerate the process of creating, deploying, and managing infrastructure resources in the cloud. CDK provides a declarative language for defining infrastructure as code, which can then be applied to automatically provision and manage cloud resources in a consistent and repeatable way.

By automating the process of infrastructure provisioning, CDK can reduce the risk of human error and inconsistency that can occur when tasks are performed manually. This is particularly important in complex environments where multiple resources must be provisioned and configured correctly in order to work together.

Automation also allows teams to focus on higher-value activities such as innovation and development, rather than manual provisioning and management of infrastructure. With CDK, teams can make infrastructure changes quickly and easily, enabling them to respond to changing business needs in real-time.

Additionally, automation can help reduce costs by optimizing resource utilization, eliminating manual processes, and reducing labor costs. CDK can help companies save money and resources by automating the process of infrastructure management and provisioning, enabling them to scale more efficiently and effectively.

How infrastructure as code works

With IaC builders define infrastructure resources such as servers, databases, and networking components using code, rather than manually provisioning them through a web console or command-line interface.

IaC works by defining the desired state of infrastructure in a declarative configuration language, which is then applied to create or modify resources in the cloud. The CDK code defines the relationships and dependencies between resources, enabling CDK to automatically manage the order in which resources are provisioned and configured.

The benefits of infrastructure as code include increased efficiency, consistency, and scalability. By using code to define infrastructure resources, teams can automate the provisioning and management of infrastructure, reducing the risk of human error and enabling them to scale more efficiently. Additionally, infrastructure as code provides version control and audit trail capabilities, making it easier to track and manage infrastructure changes over time.

Infrastructure as code also enables teams to work collaboratively and efficiently, with code serving as a shared language for communicating infrastructure changes and requirements. With CDK, teams can work together to define infrastructure resources using a common syntax, enabling them to streamline the process of infrastructure management and provisioning.

How CDK works on AWS

CDK works on AWS by leveraging the AWS API to automate the provisioning and management of infrastructure resources in the cloud. CDK provides a declarative configuration language that allows users to define their desired infrastructure state as code, and then applies that code to create, modify, and delete resources on AWS.

To use CDK on AWS, users first define their AWS credentials and configuration settings in a CDK configuration file. This file specifies the resources to be created and their properties, as well as any dependencies and relationships between resources. The CDK configuration file is then used to generate a plan, which outlines the changes that CDK will make to the existing infrastructure in order to bring it into the desired state.

Once the plan has been reviewed and approved, CDK applies the changes to the infrastructure in a safe and predictable manner. CDK uses the AWS API to provision and configure resources in the correct order, ensuring that dependencies are met and that resources are provisioned correctly. CDK also provides support for AWS-specific features, such as auto-scaling groups, elastic load balancers, and virtual private clouds, allowing users to manage complex AWS infrastructure with ease. Additionally, CDK can be integrated with other AWS services, such as CloudWatch and S3, to enable monitoring and storage of CDK state files.

Overall, CDK provides a powerful and flexible way to manage infrastructure on AWS, allowing users to automate the provisioning and management of resources at scale while maintaining consistency and predictability.

AWS CloudFormation, AWS CDK, and Terraform

AWS CloudFormation, AWS Cloud Development Kit (CDK), and Terraform are all infrastructure as code tools that enable users to define, provision, and manage cloud resources in a declarative and automated way.

The AWS CDK provides a high-level object-oriented abstraction over AWS CloudFormation. Using the CDK, developers can define infrastructure as code using a programming language such as TypeScript or Python, and then use the AWS CDK toolkit to generate CloudFormation templates and deploy them to AWS. Terraform is a popular open-source tool that can be used to provision and manage infrastructure on a variety of cloud providers, including AWS. Terraform uses a declarative configuration language to define infrastructure resources, and can be used to automate the provisioning of resources in a safe and predictable manner.

AWS CloudFormation is a native AWS infrastructure as code tool that provides a JSON or YAML-based declarative language to describe and provision infrastructure resources. CloudFormation templates can be used to automate the creation of complex architectures, and can be version-controlled and reused across multiple environments.

While each tool has its own strengths and weaknesses, they all provide powerful ways to automate the management of infrastructure on AWS. Terraform offers a wide range of providers and a powerful configuration language, while the AWS CDK offers a programming language-based approach to infrastructure as code, and CloudFormation provides a native, AWS-focused solution. Ultimately, the choice between these tools will depend on the specific needs and preferences of each individual organization.

Getting unstuck

In each chapter we will provide a “Getting Unstuck” section that provides troubleshooting tips and resources for common issues that may arise during the project. We will also provide a “Chapter Synth” that summarizes the chapter and a “Discussion” section that includes questions to help you review the material. Finally, we will provide “Extension Activities” that include optional exercises to help you apply your knowledge in new contexts.

Chapter Synth

This book is for you. We wrote it to help you learn or expand your knowledge of CDK. You can read it in order, out of order, or as a choose your own adventure text. Each chapter begins with a project, and we did that on purpose to make the book engaging and to make the knowledge stick.

In this chapter you learned:

  1. How to set up an AWS account

  2. How to set up an IAM user for CDK development

  3. How to access your AWS IAM user for CDK development from the command line

  4. How to install all of your software prerequisites

  5. How to set up your development environment

Now you are ready to build your first very simple CDK application. Let’s go!

Discussion

At the end of each chapter we include discussion questions that help you review. If these questions are challenging, you can review the corresponding parts of the chapter. These questions are open book.

  1. What is the difference between a CDK application, stack, and construct? What qualities do they share in common? How are they different?

  2. Review the official CDK developer docs. Try to find one example of an L1 construct, one of an L2 construct, and one of an L3 construct.

  3. How are CDK, Cloudformation, and the Cloud Control API related? How are they different?

Extension activities

At the end of each chapter we also include a few extension activities. These activities are optional and often involve applying your knowledge in a new context. Try them out right away, or bookmark and return to them later.

  1. Visit the official CDK documentation located and consider following some of the getting started tutorials.

  2. Try writing your own brief CDK getting started guide. Try to fit all the steps into a single page or single sheet of paper. What special tips would you highlight?

  3. Find someone (preferably someone who is interested) and explain to them the benefits of AWS CDK and how it can help businesses innovate.

Get Hands-On AWS CDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.