AWS Exam GuidesNewsletterBlogContact

👋 Hey! My name is Wojciech Gawroński, but others call me AWS Maniac.

My goal is to safely guide you through the cloudy and foggy space of the AWS portfolio.

AWS CDK and Tests

1 min read, last updated on 2020-12-22

Before we move forward, we need to talk about testability. AWS CDK gives us unique selling points and mechanisms related to testing. Let’s review them!

The main problem with the Feedback Loop

If you are working with the AWS CloudFormation, you probably do not need to read another paragraph at all - you already feel the pain.

When working with templates and iterating with infrastructure scripts, time is crucial. In most cases, we need to update or create a stack, wait, and we will discover errors in the runtime one by one. This is tedious, problematic, and wasteful.

With pure CloudFormation, you have to fallback to additional tools or use a totally different tool (e.g., Terraform) to achieve testability and shortening the feedback loop.

Luckily, we have exciting options related to testing tools.

Unit Testing in AWS CDK

We need to start with an explanation that the unit tests are verifying the generated output and templates. This may sound like a simplistic and crude approach, but actually, it allows for more, as we can perform the following elements:

  • Evaluating differences and snapshots (which represents the frozen state of the infrastructure graph after synthesis).
  • Very precise assertions about resources and their condition.
  • Testing validation rules (e.g., length of the attributes - like name and similar), passed parameters, and constructs.

We will see all those techniques in practice in future blog posts!


Please bear in mind that all we talked about do not invalidate the need for integration tests. It helps with testability. It shortens the feedback loop and builds a safety net for our infrastructure scripts and infrastructure as code.

Subscribe to the newsletter and get notifications about new posts.


👋 Hey! My name is Wojciech Gawroński, but some people call me AWS Maniac. I am your trusted guide through the AWS Madness. If you want to learn more about me, you can start here.

Share it:

YouTube, Twitter, LinkedIn, Instagram, Facebook
awsmaniac.com © 2021, built with Gatsby and template from @kjendrzyca