Create CDK Project

Create CDK Project

  1. Change the directory to the main repo and install nvm
cd my-eks-blueprints
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
source ~/.bashrc
nvm -v

Create Workspace

  1. Use Node.js version 18
nvm install v18
nvm use v18
node -v
npm -v

Create Workspace

You need to use Node.js version 14.15.0 or higher to use CDK. For more information, see here Create Workspace

  1. Install TypeScript and CDK version 2.147.3
npm -g install typescript
npm install -g aws-cdk@2.147.3
cdk --version

Create Workspace

  1. Initialize a new CDK project using TypeScript
cdk init app --language typescript

Create Workspace

  1. In the VSCode interface
    • View the sidebar
    • Examine the structure of the project
    • lib/: This is where the stacks or constructs of your CDK project are defined. Create Workspace
    • bin/my-eks-blueprints.ts: This is the entry point of the CDK project. It will load the constructs defined in lib/. Create Workspace

You can read more about CDK.

  1. Set the AWS_DEFAULT_REGION and ACCOUNT_ID
export AWS_DEFAULT_REGION=ap-southeast-1
export ACCOUNT_ID=212454837823

Note: Remember to replace ACCOUNT_ID with your actual ID for the lab.

Create Workspace

  1. Initialize the bootstrap account

To perform bootstrapping, run:

cdk bootstrap --trust=$ACCOUNT_ID \
  --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess \
  aws://$ACCOUNT_ID/$AWS_REGION

On successful bootstrapping, you will see:

Environment aws://212454837823/ap-southeast-1 bootstrapped.

Create Workspace

  1. Install the eks-blueprints and dotenv modules for the project
npm i @aws-quickstart/eks-blueprints dotenv

Create Workspace