Prepare and Download packages

(a) AWS CLI Installed:

AWS CLI is installed by default if using Cloud9 service. If you would like to use your own local shell, please follow these instructions if you haven’t installed AWS CLI. Your CLI configuration needs PowerUserAccess and IAMFullAccess IAM policies associated with your credentials

Please test your cli access by running the below command:

aws --version

Output from aws cli version above must yield AWS CLI version >= 1.11.37

sudo yum install -y jq
export ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account)
export AWS_REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region')
echo "export ACCOUNT_ID=${ACCOUNT_ID}" | tee -a ~/.bash_profile
echo "export AWS_REGION=${AWS_REGION}" | tee -a ~/.bash_profile
aws configure set default.region ${AWS_REGION}
aws configure get default.region

(b) Download and install Kubectl and IAM Authenticator:

Run the below command on your Cloud9 Terminal and check the last command to confirm kubectl is correctly installed:

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl help
curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.15.10/2020-02-22/bin/linux/amd64/aws-iam-authenticator
chmod +x ./aws-iam-authenticator
mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc

Ensure that /usr/local/bin is in your PATH environmental variable by running “env | grep PATH” command.

(c ) Install pre-requisite packages for the CDK:

Install / upgrade the cdk required packages using the below commands:

sudo yum install -y npm
npm install -g aws-cdk@1.30.0 --force
npm install -g typescript@latest

  • Node packages are recommended to be equal or higher than v10.16.3, check using node -v
  • CDK packages are recommended to be equal to 1.30.0, check using cdk –version
  • TypeScript packages are recommended to be equal or higher than 3.7.4, check using tsc -v

(d) Download the Application Tar file:

Run the below command on your Cloud9 Terminal to download the Application and CDK Tar file: During untar operation, you may see messages “Ignoring unknown extended header keyword”, you may ignore them.

curl -O https://awsdemoworkshops.s3.us-east-2.amazonaws.com/cicd-eks-alb-bg-cdk-workshop/Downloads/archive-eks-alb-bg.tar.gz
tar -xzvf archive-eks-alb-bg.tar.gz
cd amazon-eks-cicd-codebuild-eks-alb-bg
ls

(e) Initialize Git & commit the code:

Before running this step, please ensure that the IAM user used to access the CodeCommit, has been setup with security credentials for CodeCommit access: CodeCommit access via http

First initialize git (if not already done) and commit using following steps:

git init
git add .
git commit -m "Initial Commit"
git status
git log

Use the last 2 commands to confirm the Git is in expected state. We will push the commit to the CodeCommit repository after CDK finishes building the repository.