在多个帐户中运行AWS CLI的方法 [英] Way to run aws cli across multiple accounts

查看:51
本文介绍了在多个帐户中运行AWS CLI的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出运行非Amazon AMI映像的10个不同帐户中的所有EC2实例.以下CLI命令为我提供了所有AMI的列表:

I am trying to find out all EC2 instances in 10 different accounts which are running non-amazon AMI images. Following CLI command gives me the list of all AMI's:

aws ec2 describe-instances --output text --query 'Reservations[*].Instances[*].[ImageId]' | sort | uniq -c

我想我可以进一步修改它以获取所有非amazon AMI,但是是否可以在一个呼叫中跨10个不同帐户运行它?

I think I can modify this further to get all non-amazon AMI's but is there a way to run this across 10 different accounts in one call?

推荐答案

有没有办法一次调用10个不同帐户的帐户?

is there a way to run this across 10 different accounts in one call?

不,那不可能.您需要编写一个循环访问每个帐户的循环,并对每个帐户调用一次 ec2 describe-instances .

No, that's not possible. You need to write a loop that iterates over each account, calling ec2 describe-instances once for each account.

这篇关于在多个帐户中运行AWS CLI的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆