Project setup - solargis/cdk-workshop GitHub Wiki
Prerequisites
- nodejs v10
- Git client
- IDE (WebStorm, Visual Studio Code, ...)
- Java JRE 1.8+ (optional, for step-8 - local environment)
Environment setup
Install AWS CDK
npm install -g aws-cdk
Verify install: cdk --version
should return something like 1.13.1 (build 96cfc63)
Setup AWS credentials
Save provided AWS credentials to file (homedir): ~/.aws/credentials
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
region = eu-central-1
To use AWS profile - prefix all cdk commands with
AWS_PROFILE=[myprofile]
e.g.AWS_PROFILE=sandbox cdk ls
--profile [myprofile]
option will not work in this workshop setup
To use own AWS account - launch
cdk bootstrap
command first, to initialize CDK resources in the AWS. It takes few minutes to complete. This is already done in the provided account.
Checkout project repository
Checkout project repository with empty CDK project:
git clone https://github.com/solargis/cdk-workshop.git
cd cdk-workshop
Install npm dependencies:
npm install
Alternatively, download and extract cdk-workshop-repo.zip archive
Initial repository content:
./cdk/cdk-workshop.ts - CDK entry point, defines CDK application and stacks
./cdk/cdk-workshop-stack.ts - CDK stack definition, we will define cloud infrastructure here
./cdk.json - basic CDK configuration, link to CDK entry point
./package.json - node package config, we will add dependencies and scripts here
./tsconfig.json - TypeScript configuration for CDK code
Initial repository was created with following steps:
mkdir cdk-workshop
cd cdk-workshop
cdk init app --language=typescript
- moved CDK code from
./bin
and./lib
to./cdk
- standardized ES6 imports
- removed tests and not relevant code
Run CDK commands:
cdk ls
- list stacks in current CDK applicationcdk synth
- synthetize CloudFormation stack templatecdk diff
- show changes between deployed CloudFormation stack and current stack in CDK code
Deploy initial stack into AWS
cdk deploy
- Navigate to AWS Console: https://solargis-sandbox.signin.aws.amazon.com/console
- Sign in with username
userXY
and passworduserXYuserXY
- Ensure region is switched to EU (Frankfurt)
region switch is located in the header on the right side
- Navigate to Services > CloudFormation and check stack creation status