Amazon Web Services (AWS) - Determine if an EC2 instance is associated with an Instance Profile using the AWS CLI

by
Jeremy Canfield |
Updated: May 28 2024
| Amazon Web Services (AWS) articles
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
An EC2 instance can only be associated with one instance profile. The aws ec2 describe-iam-instance-profile-associations command to determine if one of your EC2 instances is associated with an instance profile.
~]$ aws ec2 describe-iam-instance-profile-associations
{
"IamInstanceProfileAssociations": [
{
"AssociationId": "iip-assoc-04a03786337a32660",
"InstanceId": "i-0a3ea97aa2383de58",
"IamInstanceProfile": {
"Arn": "arn:aws:iam::123456789012:instance-profile/my-instance-profile",
"Id": "AIPA2MITL76GNDM4CZFIM"
},
"State": "associated"
}
]
}
Did you find this article helpful?
If so, consider buying me a coffee over at