-
Notifications
You must be signed in to change notification settings - Fork 157
/
check
executable file
·15 lines (14 loc) · 1.13 KB
/
check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
echo "Checking workshop setup ..."
instid=`curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id`
iname=$(aws ec2 describe-tags --filters "Name=resource-type,Values=instance" "Name=resource-id,Values=$instid" | jq -r '.Tags[] | select(.Key=="Name").Value')
echo $iname| grep 'eks-terraform\|-Project-mod-' -q && echo "PASSED: Cloud9 IDE name is valid " || echo "ERROR: Cloud9 IDE name invalid! - DO NOT PROCEED"
#echo $instid
aws sts get-caller-identity --query Arn | grep eksworkshop-admin -q && echo "PASSED: IAM role valid" || (echo "ERROR: IAM role not valid - DO NOT PROCEED" && echo "Check Cloud9 AWS Managed temporary credentials are disabled - in AWS Settings")
ip=`aws ec2 describe-iam-instance-profile-associations --filters "Name=instance-id,Values=$instid" | jq .IamInstanceProfileAssociations[0].IamInstanceProfile.Arn | rev | cut -f1 -d'/' | rev | tr -d '"'`
#echo "Instance Profile=$ip"
if [ "$ip" != "eksworkshop-admin" ] ; then
echo "ERROR: Could not find Instance profile eksworkshop-admin - DO NOT PROCEED"
exit
else
echo "PASSED: Found Instance profile $ip - proceed with the workshop"
fi