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

已提問 5 年前檢視次數 2023 次
1 個回答
0
已接受的答案

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
已回答 5 年前
profile picture
專家
已審閱 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南