hands-on lab

Evaluating CDK Constructs with Fine-Grained Assertions and Validation Tests

Difficulty: Intermediate
Duration: Up to 45 minutes
Students: 33
Rating: 3.6/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

Custom CDK constructs allow organizations to implement specific configurations on AWS services to meet their requirements. Although writing custom constructs provides the guardrails to allow this, the development of the constructs themselves requires a form of testing to ensure these requirements are met. The Snapshot Testing AWS CDK Constructs hands-on lab introduced the built-in Jest testing framework and how to incorporate snapshot tests into your CDK development process. 

Snapshot tests verify that a construct will generate the same template resource definition every time, but how can developers ensure the constructs are utilized correctly while they build out their applications?

Fine-grained assertions are tests that drill down to the individual properties of your constructs and ensure that specific values are set. Validation tests check your CDK constructs to make sure they raise the appropriate errors when you pass them invalid data. 

In this lab, you will write fine-grained assertions and validation tests to evaluate a custom Amazon Kinesis stream construct.

Learning Objectives

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

  • Write fine-grained assertions to assess CDK construct features
  • Write validation tests to ensure correct construct erroring behavior

Intended Audience

  • Cloud Architects
  • DevOps Engineers
  • Software Engineers

Prerequisites

Familiarity with the following will be beneficial:

  • AWS Cloud Development Kit
  • TypeScript Programming
  • Jest Testing Framework
  • JavaScript Object Notation (JSON)

Refer to the following labs to fulfill the prerequisite:

Environment before

Environment after

Covered topics

Hands-on Lab UUID

Lab steps

0 of 2 steps completed.Use arrow keys to navigate between steps. Press Enter to go to a step if available.
  1. Assessing Construct Features with Fine-grained Assertions
  2. Securing Construct Behavior with Validation Tests