Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which role is attached to instance

How to check which IAM roles and it's policy json, are attached to the running EC2 instance?

Is it possible through AWS CLI?

Here the response for aws ec2 ddescribe-instances enter image description here

I tried firing the command - aws iam list-instance-profiles,
it gave me the following error -

An error occurred (AccessDenied) when calling the ListInstanceProfiles operation: User: is not authorized to perform: iam:ListInstanceProfiles on resource:

like image 931
Ani Avatar asked Sep 07 '16 04:09

Ani


1 Answers

No need to look for AWS CLI installed your Machine, Just machine should have internet and no block from metadata. You can curl the metadata from EC2:

curl -s http://169.254.169.254/latest/meta-data/iam/info |grep InstanceProfileArn  | awk '{print $3}'
like image 195
Praveen Gowda Avatar answered Oct 15 '22 00:10

Praveen Gowda