Amazon Web Services (AWS) - List Instance Profiles using the AWS CLI

by
Jeremy Canfield |
Updated: January 24 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.
The aws iam list-instance-profiles command can be used to list the Instance Profiles you have created. If no role have been attached to the Instance Profile, something like this should be returned, where Roles is an empty list.
~]$ aws iam list-instance-profiles
{
"InstanceProfiles": [
{
"Path": "/",
"InstanceProfileName": "my-instance-profile",
"InstanceProfileId": "AIPA2MITL76GNDM4CZFIM",
"Arn": "arn:aws:iam::123456789012:instance-profile/my-instance-profile",
"CreateDate": "2024-01-26T02:20:03+00:00",
"Roles": []
}
]
}
If one or more Roles have been attached to the Instance Profile, something like this should be returned.
~]$ aws iam list-instance-profiles
{
"InstanceProfiles": [
{
"Path": "/",
"InstanceProfileName": "my-instance-profile",
"InstanceProfileId": "AIPA2MITL76GNDM4CZFIM",
"Arn": "arn:aws:iam::123456789012:instance-profile/my-instance-profile",
"CreateDate": "2024-01-26T02:20:03+00:00",
"Roles": [
{
"Path": "/",
"RoleName": "test",
"RoleId": "AROA2MITL76GF46NSCA6E",
"Arn": "arn:aws:iam::123456789012:role/my-role",
"CreateDate": "2024-01-26T02:13:17+00:00",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:user/johndoe"
},
"Action": "sts:AssumeRole",
"Condition": {}
}
]
}
}
]
}
]
}
Did you find this article helpful?
If so, consider buying me a coffee over at