We highly recommend using Cloud9 to setup and interact with this workshop. While you can use your own terminal, the steps in this workshop have been tested and optimized to work with Cloud9. If you choose not to use Cloud9, this workshop assumes that you will use an equivalent alternative.
Cloud9 normally manages IAM credentials dynamically. At this time, this feature is not compatible with the aws-iam-authenticator plugin, so we will disable it and rely on the IAM role instead.
In the AWS Management Console on the Services menu, click Cloud9
.
Click Open IDE
on the observabilityworkshop
Cloud9 instance.
Click the gear icon in the top right to open the Prefences
tab.
Select AWS SETTINGS
from the left navigation menu.
Toggle off the AWS managed temporary credentials
setting.
Close the Preferences
tab.
Navigate to the terminal at the bottom of the screen. (If you do not see a terminal, click Window
from the top menu, then New Terminal
)
This script ensures that no temporary credentials are already in place by removing any existing credentials file.
rm -vf ${HOME}/.aws/credentials
This script installs all the necessary tools and utilities required. It also downloads the source code required for the workshop.
curl -sSL https://raw.githubusercontent.com/aws-samples/one-observability-demo/main/PetAdoptions/envsetup.sh | bash -s stable
This script configures the AWS CLI to use the current region as the default.
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
If you are not using Cloud9, skip this step and continue to the Install CDK packages step.
This script validates that your environment settings are correct.
test -n "$AWS_REGION" && echo AWS_REGION is "$AWS_REGION" || echo AWS_REGION is not set
aws sts get-caller-identity --query Arn | grep observabilityworkshop-admin -q && echo "You're good. IAM role IS valid." || echo "IAM role NOT valid. DO NOT PROCEED."
When using Cloud9, if the IAM role is not valid, DO NOT PROCEED. Go back and confirm the steps on this page.
This command will navigate you to the
pet_stack
folder.
cd workshopfiles/one-observability-demo/PetAdoptions/cdk/pet_stack
This command installs all npm packages.
npm install
This command installs the Bootstrap CDK.
If you are not in the pet_stack
folder go there by executing this - cd workshopfiles/one-observability-demo/PetAdoptions/cdk/pet_stack
cdk bootstrap
<Enter your Role ARN>
with the ARN of your current AWS Identity.A new EKS Console was recently introduced by AWS. In order to have full access to the new Console, some permissions needs to be granted inside the EKS Cluster RBAC as described here. This command adds permissions to access the EKS Console.
CONSOLE_ROLE_ARN=<Enter your Role ARN>
These commands deploy the PetAdoptions application stack to your AWS account.
EKS_ADMIN_ARN=$(../../getrole.sh)
echo -e "\nRole \"${EKS_ADMIN_ARN}\" will be part of system:masters group\n"
if [ -z $CONSOLE_ROLE_ARN ]; then echo -e "\nEKS Console access will be restricted\n"; else echo -e "\nRole \"${CONSOLE_ROLE_ARN}\" will have access to EKS Console\n"; fi
cdk deploy --context admin_role=$EKS_ADMIN_ARN Services --context dashboard_role_arn=$CONSOLE_ROLE_ARN --require-approval never
cdk deploy Applications --require-approval never
It will take a few minutes for the stack to be deployed, so feel free to take a coffee break here ☕️
These commands update kubeconfig so you can interact with the EKS cluster
aws eks update-kubeconfig --name PetSite --region $AWS_REGION
kubectl get nodes
After execution, your output should look like the below screenshot:
aws ssm get-parameter --name '/petstore/petsiteurl' | jq -r .Parameter.Value
You can navigate through the application as shown below.
In very rare cases, you might encounter a behavior where the site does not show any pet images. Click on Perform Housekeeping
in the PetSite home page upper right corner.