hands-on lab

Defining Cloud Infrastructure with the AWS CDK v2 in Python

Difficulty: Intermediate
Duration: Up to 1 hour
Students: 442
Rating: 4/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework used to define your cloud application resources using familiar programming languages.

Before the AWS CDK, you had to rely heavily on AWS CloudFormation or AWS Serverless Application Model (AWS SAM) to define your cloud application resources, which required a decent understanding of YAML or JSON. The AWS CDK provides a programming model above these native template languages that increase productivity when developers are building out their infrastructure as code.

The AWS CDK includes the AWS Construct Library which supports many AWS services and configurations as well as the AWS CDK Toolkit which serves as the primary tool for instantiating and deploying your resources to AWS CloudFormation.

In this lab, you will use the AWS CDK Toolkit to create an AWS CloudFormation stack using the Python programming language.

The majority of the steps in this lab will be performed in a code IDE, but you will be logging into the AWS console in the later stages of the lab to verify and test the resources spun up by the AWS CDK.

Important: This hands-on lab uses the latest AWS CDK v2. For hands-on labs and challenges that use the AWS CDK v1, refer to the Get Hands-on with the AWS Cloud Development Kit (CDK v1) learning path.

Learning Objectives

Upon completion of this intermediate-level lab, you will be able to:

  • Initialize a new AWS CDK project
  • Employ constructs from the AWS Construct Library in Python
  • Use the AWS CDK Toolkit to synthesize and deploy an AWS CloudFormation template
  • Invoke an AWS Lambda function with an Amazon S3 bucket event notification

Intended Audience

  • Cloud Architects
  • DevOps Engineers
  • Software Engineers

Prerequisites

Familiarity with the following will be beneficial but is not required:

  • Python
  • AWS CloudFormation
  • AWS Lambda
  • Amazon Simple Storage Service (S3)

The following content can be used to fulfill the prerequisite:

Updates

April 17th, 2024 - Resolved IAM permission issue

August 16th, 2023 - Remove Node deprecation warning and updated CDK CLI version

May 8th, 2023 - Resolved S3 bucket deployment error

March 13th, 2023 - Enabled autosave in the lab's browser IDE

October 3rd, 2022 - Resolved CDK command issue

 

Environment before

Environment after

Covered topics

Lab steps

Logging In to the Amazon Web Services Console
Initializing an AWS CDK Application in Python
Simplifying Infrastructure Development with Curated CDK Constructs
Deploying AWS Resources with the AWS CDK CLI
Testing the AWS CDK Application