EC2 instance tricks

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Check the AWS Account id
curl \
  http://169.254.169.254/latest/dynamic/instance-identity/document \
  | grep accountId \
  | awk '{print $3}' \
  | sed 's/"//g' \
  | sed 's/,//g'

# check the assigned role
aws sts get-caller-identity