Setup version control

AWS CodeCommit is a version control service that enables you to privately store and manage Git repositories in the AWS cloud.

To add a AWS CodeCommit Repository to your AWS CDK stack please do the following:

Open NorthwindCdk.sln in Visual Studio.

Add Amazon.CDK.AWS.CodeCommit Nuget package to the project:

CodeCommit Nuget

Open NorthwindCdkStack.cs.

Add following using statement:

using Amazon.CDK.AWS.CodeCommit;

Please add the following changes at the end of NorthwindCdkStack constructor:

namespace NorthwindCdk
    public class NorthwindCdkStack : Stack
        internal NorthwindCdkStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)

            // CodeCommit

            var codeRepository = new Repository(this, "NorthwindCodeRepository", new RepositoryProps
                 RepositoryName = "Northwind",
                 Description = "Northwind code repository"

            new CfnOutput(this, "CodeRepository", new CfnOutputProps
                Value = codeRepository.RepositoryCloneUrlHttp


The code above creates new AWS CodeCommit repository and outputs it’s HTTP url.

Save changes and compile the project.

Run cdk diff to take a look at the changes that are going to be deployed.

cdk diff

The output should look like this:

Stack NorthwindCdkStack
[+] AWS::CodeCommit::Repository NorthwindCodeRepository NorthwindCodeRepository9CDB75DD

[+] Output CodeRepository CodeRepository: {"Value":{"Fn::GetAtt":["NorthwindCodeRepository9CDB75DD","CloneUrlHttp"]}}

Next deploy the updates using cdk deploy command.

cdk deploy

The output should look like this:

NorthwindCdkStack: deploying...
NorthwindCdkStack: creating CloudFormation changeset...
 0/3 | 10:14:54 AM | CREATE_IN_PROGRESS   | AWS::CodeCommit::Repository           | NorthwindCodeRepository (NorthwindCodeRepository9CDB75DD)

 ✅  NorthwindCdkStack

NorthwindCdkStack.CodeRepository =
NorthwindCdkStack.PostgreSQLEndpointAddress =

Stack ARN:

Please note code repository URL from the stack output above You will need it later to configure remote repository.