hands-on lab

Testing AWS CDK Constructs with Fine-grained Assertions

Intermediate
1h
129
5/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.
Lab description

The AWS CDK provides an Assertions module that allows you to test the AWS CloudFormation template that is generated by your CDK application. The CDK also supports testing your application with the Pytest framework to enable local, test-driven development.

This lab will focus on writing fine-grained assertion tests to evaluate your CDK resources and ensure they've been configured with the appropriate properties. With that in mind, you will not be deploying the application used in this lab. In this lab, you will work with the Template, Capture, and Match constructs to build out efficient unit tests that can detect regressions as you develop new application features.

Learning Objectives

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

  • Explore the AWS CDK Assertions module
  • Write fine-grained assertions that test the generated AWS CloudFormation template
  • Run tests using the Pytest framework

Intended Audience

  • Cloud Architects
  • DevOps Engineers
  • Software Engineers

Prerequisites

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

  • AWS CDK
  • Amazon SNS
  • Amazon SQS
  • AWS Lambda
  • AWS IAM

The following content can be used to fulfill the prerequisite:

Updates

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

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

About the author
Avatar
Jun Fritz
Cloud Labs Developer
Students
38,452
Labs
103
Courses
1
Learning paths
6

Jun is a Cloud Labs Developer with previous experience as a Software Engineer and Cloud Developer. He holds the AWS Certified Solutions Architect and DevOps Engineer Professional certifications. He also holds the AWS Certified Solutions Architect, Developer, and SysOps Administrator Associate certifications. 

Jun is focused on giving back to the growing cloud community by sharing his knowledge and experience with students and creating engaging content. 

Covered topics
Lab steps
Setting up the AWS CDK Project for Testing
Synthesizing a Test Template and Counting Resources
Capturing and Matching Values with the CDK Assertion Classes