AWS CDK workshop troubleshooting notes

CDK is a new way to manage infrastructure as code(IaC). It looked interesting but I never got to work with CDK much. I recently swithced my roles to become a software engineer at Amazon and we heavily use CDK for our CI/CD pipelines. So I need to practice and get better at using CDK. While doing this CDK pipeline workshop(link below), I ran into a bunch of issues. Here are my troubleshooting notes.

https://cdkworkshop.com/20-typescript/70-advanced-topics/200-pipelines

Issue 1: This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version. (Cloud assembly schema version mismatch: Maximum schema version supported is 8.0.0, but found 9.0.0)

Uninstall the CDK version:

npm uninstall -g aws-cdk

Install specfic version which your application is using. For ex: CDK 1.158.0

npm install -g aws-cdk@1.158.0

Reference: https://stackoverflow.com/questions/66565550/how-to-solve-cdk-cli-version-mismatch


Issue 2: When trying to push code to codecommit you get this error error: src refspec main does not match any

Check the local branch name. If you’re trying to push to the main remote branch and your local branch is master you’ll run in to this error. Fix this by renaming the local branch to main and push to remote after that.

git master -m main
git push


Issue 3: TS2304: Cannot find blob

add the dom entry to the lib in tsconfig.json. Your tsconfig file should look like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"compilerOptions": {
"target":"ES2020",
"module": "commonjs",
"lib": ["es2020", "dom"],
"outDir": "dist",
"resolveJsonModule": true,
},
"exclude": [
"coverage",
"node_modules",
"dist",
"tests"
]
}

Reference: https://stackoverflow.com/a/66275649

CloudFormation and Soccer connection

October 31, 2020

I’m a soccer fan. When I first heard about CloudFormation this image was something that came to my mind.

After learning a few intermediate CloudFormation components like parameters and mappings and custom resources, this is how I think of CloudFormation now.

Some analogies between CloudFormation and Soccer:

  • In Soccer, to play a game, all you need is a ball. Similarly in Cloudformation, to launch a stack, the only section required in a template is a resources section with at least 1 resource.

  • Stack updates are like player substitution( or even a ball substitution) in a professional Soccer game

  • CloudFormation has certain limits just like a professional soccer game. The new per template limits for the maximum number of resources is 500 (previously 200), parameters is 200 (previously 60), mappings is 200 (previously 100), and outputs is 200 (previously 60). This is similar to max numbers of players in a soccer game ( 11 per side), max number of substitute on bench( 7), max allowed substitution per game (3).

I’ll add more analogies in the future when they come to me. If you have any suggestions, let me know in the comments.

By the way, you can read about the new limits for Cloudformation here which lets you work with more resources/parameters/outputs per template.