Now that your instance is ready and docker is installed it is time to build the container and upload it to Amazon ECR:
cat << EOF > ~/Dockerfile
FROM public.ecr.aws/amazonlinux/amazonlinux:2
RUN amazon-linux-extras install epel -y && yum install stress-ng -y
CMD /usr/bin/stress-ng
EOF
cd ~
AWS_ACCOUNT_ID
and AWS_REGION
. If further guidance is needed, follow this guide.!/bin/bash
sudo yum install jq
# set environment variables
AWS_ACCOUNT_ID=`aws sts get-caller-identity | jq -r '.Account'` # or replace by your account ID
export AWS_REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/region) # or replace by your region
ECR_URL=`aws cloudformation describe-stacks --stack-name LargeScaleBatch --query "Stacks[0].Outputs[?OutputKey=='ECRRepositoryUrl'].OutputValue" --output text --region ${AWS_REGI\
ON}`
ECR_BASE_DIRECTORY=$(echo "$ECR_URL" | cut -d "/" -f1)
# Authenticate with ECR
aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${ECR_BASE_DIRECTORY}
# Build the image
docker build -f ~/Dockerfile -t ${ECR_URL}:latest .
# Push your image to your ECR repository
docker push ${ECR_URL}:latest
By this point in the workshop, you should have
Now you will now run a test workload in AWS Batch to evaluate its behavior.