Get a list of all managed instance Ids

0

I need to be able to run a command from aws ssm cli to output a list.

How to a do this from cli? I just need a csv list of every mi-xxxxxxx entry. Then, once I have that...I can use the list to feed this command:

aws ssm update-managed-instance-role --instance-id "mi-xxxxxxx" --iam-role "My_Other_ROLE"

I can change the role one at a time in the console for each mi, but I need to be able to do this programmatically.

Edited by: kleinberger on Feb 22, 2019 9:39 AM

asked 5 years ago1933 views
1 Answer
0
Accepted Answer

Hi,

This example command will get list of managed instances.
aws ssm describe-instance-information --filters Key=ResourceType,Values=ManagedInstance --query "InstanceInformationList[].InstanceId" --output text

In addition, you can also filter by IAM role like this:
aws ssm describe-instance-information --filters Key=ResourceType,Values=ManagedInstance Key=IamRole,Values=MyExampleRole --query "InstanceInformationList[].InstanceId" --output text

Hope this helps.

Thanks,
Mani

AWS
answered 5 years ago
profile picture
EXPERT
reviewed 4 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions