Create CDK project

Create new empty folder:

mkdir northwind-cdk
cd northwind-cdk

You create a new AWS CDK project by invoking cdk init in an empty directory. cdk init uses the name of the project folder to name various elements of the project, including classes, subfolders, and files. The resulting project includes a reference to the Amazon.CDK NuGet package. It and its dependencies are installed automatically by NuGet.

That is why it was important to update CDK to the latest version to have consistent version number in bootstrapped project and the NuGet packages you are going to install in later modules.

Run cdk init from within that folder with following parameters:

  • app is empty template for a CDK Application
  • --language csharp specifies that you want to use C# language
cdk init app --language csharp

You will see the output like this (please note that project name NorthwindCdk is based on the name of folder you created):

Applying project template app for csharp
Project `NorthwindCdk\NorthwindCdk.csproj` added to the solution.

# Welcome to your CDK C# project!

This is a blank project for C# development with CDK.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

It uses the [.NET Core CLI](https://docs.microsoft.com/dotnet/articles/core/) to compile and execute your project.

## Useful commands

* `dotnet build src` compile this app
* `cdk deploy`       deploy this stack to your default AWS account/region
* `cdk diff`         compare deployed stack with current state
* `cdk synth`        emits the synthesized CloudFormation template

Open newly generated NorthwindCdk.sln in Visual Studio.

Open NorthwindCdkStack.cs. This is empty placeholder stack where you will add your code.

using Amazon.CDK;

namespace NorthwindCdk
{
    public class NorthwindCdkStack : Stack
    {
        internal NorthwindCdkStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            // The code that defines your stack goes here
        }
    }
}