The CDK Book - GO Code

The CDK Book is a book by Sathyajith Bhat, Matthew Bonig, Matt Coulter, Thorsten Hoeger written end of 2021.

The code for the book is jsii generated, and there are samples for TypeScript, Python, Java and C#.

At the time beeing there are no GO samples in the book. So here I create some of the Samples for you.

Whenver it is possibly I provide synth-able code snippets, that means cdk synth produces an output. The examples usually do not generate useful code, they are just learning examples

If the snippets are to small, I provide a readme.

* TCB = The CDK Book

TCB* Chapter 2: What Are Constructs?

TCB Chapter 2.2.3. Level 2 Constructs

TCB Chapter 2.3.1. The Stack Construct

TCP Chapter 4.2.2 Tasks

As an alternative: see Chapter Tools-Task

TCP Chapter 4.2.3 Debugging

Debugging should work out of the box with vscode:


Just start (1) Debugging.

Standard Launch Json:

    "version": "0.2.0",
    "configurations": [
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}"

TCP Chapter 4.2.4 Linting

.. is included in GO.

For formatting run : go fmt *.go

TCP Chapter 5 Project Layout

Notes on files:

  • tsconfig.json - not needed with GO

  • package.json - the go.mod has almost the same functionality, see Chapter Modules

  • .gitignore - the same functionality

  • .npmignore - not needed



  • bin/* => main/main.go
  • lib/* => files wil be in the project root and subdirs


As GO does not need so much helper files and handles dependencies better since 1.13, projen is not needed. Please note: projen is not CDK standard project layout.

TCP Chapter 5.1.11. Initializing with the CLI

npx cdk init app --language=go


npx cdk init app -l=go

TCP Chapter 6 Custom Resources and CFN Providers

TCP Chapter 6.1.1. Implementing custom resources using AWS CDK

TCP Chapter 6.2. CloudFormation Resource Types

TCP Chapter 7. Configuration Management


TCP Chapter 7.1. Configuration Management


TCP Chapter 7.1. Static Files

The kind of configuration is different for the several languages.

Here an example for using Systems Manager with paddle “” and configuration files with “viper” “”

The example is a working webserver instance example. Note the in the source directory

TCP Chapter 7.3.1. Systems Manager Parameter Store

awsssm.NewStringParameter(stack, aws.String("Parameter"),
		AllowedPattern: aws.String(".*") ,
        Description:   aws.String("The value Foo"),
        ParameterName: aws.String("FooParameter"),
        StringValue:   aws.String("Foo"),
		Tier: awsssm.ParameterTier_ADVANCED,

TCP Chapter 8.3.1 Docker Image Asset in Action: ECS Fargate

A similar example is in the architecture section

TCP 8.4.1. S3 Assets in Action: Deploying Lambda Functions using S3 Assets

A similar example is in the Lambda Construct section:

TCP 8.5 Docker Bundling

TCP 9 Testing

Most of the concepts are described with code examples in


See the full source on github.