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年前2008ビュー
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
エキスパート
レビュー済み 25日前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ