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

demandé il y a 5 ans2036 vues
1 réponse
0
Réponse acceptée

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
répondu il y a 5 ans
profile picture
EXPERT
vérifié il y a un mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions