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년 전2036회 조회
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
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠