Tidy Cloud AWS issue #9 - AWS CDK and Pulumi

Hello all!

My regular laptop, a 2018 MacBook Pro, had an unfortunate accident. I tripped on the power cable and the laptop crashed down on the floor. Unfortunately, the screen broke, but the laptop itself was still working otherwise. I brought out my old 2012 MacBook Pro instead. It does not have this kind of risk, because of its MagSafe connector. The keyboard is also nicer on my old laptop than it was on the newer one. I will get the repaired laptop in a few days. Until then, I will enjoy the keyboard on my old laptop. A few notes for your enjoyment in this bulletin - the cross-language testing module for AWS CDK is now stable. The experimental APIs are available for AWS CDK version 2 also. Plus, Pulumi has some new content for you to learn about infrastructure-as-code with Pulumi.

Testing AWS CDK apps

The AWS Developer Tools blog posted a nice blog post about the new testing module that is part of AWS CDK. AWS CDK included a Typescript/Javascript specific module for testing with the name @aws-cdk/asserts, based on Jest test framework.

The new assertions module is available for all AWS CDK languages. There are two main types of test support provided - snapshot testing and fine-grained assertions. Snapshot testing is that you save the generated CloudFormation template as a point in time state. You then make comparisons in future tests if they differ or not. That way, you can capture if you would get any unintended changes to your generated infrastructure.

Fine-grained assertions go more in depth into what CloudFormation AWS CDK generates under the hood. This means that you should understand CloudFormation to well use it. You can test both what CloudFormation resources there are and their properties.

The assertions module does not enforce any specific testing framework, contrary to the old asserts module. You can use it with whatever testing framework you prefer. You can also do other types of tests on your AWS CDK code, of course. This is an added and useful tool to test what your AWS CDK code generates in terms of CloudFormation.

I can recommend trying to include tests in your infrastructure definitions, in particular if you are building re-usable constructs in AWS CDK. It can save plenty of pain to do that right from the start. (I have suffered consequences of not doing that…)

The assertions module API is stable as of AWS CDK release 1.132.0 and 2.0.0-rc.28. Here is the link again to the AWS Developer Tools blog post about the assertions module.

AWS CDK v2 experimental modules

The AWS CDK is slowly going towards the general availability of the new major release, version 2. It is mainly about better organisation, and removing deprecated functionality.

This has led to that only those modules and APIs that are stable are part of the AWS CDK version 2 releases. In version 1, stable and experimental APIs are mixed with each other. It is easy to miss which APIs were stable or experimental, and it is not clear from version numbers either.

Until now, there was no way to get to the experimental modules if you used one of the version 2 release candidates. A recent announcement changed this though, and now experimental module APIs are available as alpha modules.

Your code becomes quite clear what modules are stable, and which ones are experimental.

The AWS Developer Tools blog has a nice post that announces this update and goes through in more detail how it works. Check it out!

New Pulumi Learn

Pulumi is a relative newcomer to the infrastructure-as-code space, but also a veteran in infrastructure-as-code with programming languages such as Go, Python, and Typescript.

They do a good job of producing content to educate and inform how to build solutions using Pulumi, with both blogs, YouTube videos, and multiple tutorials.

The latest tutorials include some suitable material for basic usage of Pulumi. You can run them on your computer, with no cloud platform access needed. Well done, Pulumi! The code in the tutorials is in Python, with more languages to be added later.

You can find the contents of this bulletin and older ones, and more at Tidy Cloud AWS. You will also find other useful articles around AWS automation and infrastructure-as-software.

Until next time,