Create CDK app skeleton

Create an empty directory and change to the directory:

mkdir hellocdk
cd hellocdk

To see all possibilities, type

cdk init

Now create a GO CDK App

cdk init app --language=go

Don’t be surprised, if you worked with the TypeScript CDK before, this goes fast!

cdk init app --language=typescript  16,36s user 8,55s system 113% cpu 21,933 total
cdk init app --language=go  0,57s user 0,17s system 101% cpu 0,721 total

Now we have this directory setup:

├── cdk.json
├── go.mod
├── hellocdk.go
└── hellocdk_test.go

This setup might change in future CDK versions

File  content prefilled with cdk commands
cdk.json cdk configuration
go.mod Go modules - module name is directory name
hellocdk.go main program
hellocdk_test.go main test program


  1 {
  2   "app": "go mod download && go run hellocdk.go",
  3   "context": {
  4     "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
  5     "@aws-cdk/core:stackRelativeExports": "true",
  6     "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
  7     "@aws-cdk/aws-lambda:recognizeVersionProps": true,
  8     "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true
  9   }
 10 }

In line 2 the commands, which cdk will execute are shown. Line 4…8 are CDK internal configuration. These configuration changed a lot from CDK V1 to V2.

The next step to understand the concepts fully is to take a look at the generated GO file in detail in the next chapter.