How to Get the Instance Profile attached to an AWS EC2 2022-09-14 34 words - 1 min read If you need to get the IAM Role information from the attached EC2 role directly, you can do the following: 1 2 IAM_ROLE=$(curl -s 169.254.169.254/latest/meta-data/iam/info | \ jq -r '.InstanceProfileArn' | cut -d'/' -f2)