如何获取标签EC2-描述-情况下在shell脚本 [英] How to fetch the tags for ec2-describe-instances in a shell script

查看:164
本文介绍了如何获取标签EC2-描述-情况下在shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要提取的实例ID,并从命令EC2-描述,实例的结果标签,并希望将结果存储在一个文本文件中。结果集给出了:

I want to extract the instance ID and the tags from the result of a command ec2-describe-instances and want to store the result in a text file. The result set gives :

但我想的标签所有者和cost.centre也需要抓取 请指导我该怎么做

But i want the tags owner and cost.centre also to be fetched Kindly guide me how to do that

推荐答案

这将有助于找到实例ID

this will help to find instance-id

$ AWS EC2描述,实例--filters名称= VPC-ID,值= VPC-XXX | awk的'{打印$ 8}'|排序-n | grep的我 -

$ aws ec2 describe-instances --filters Name=vpc-id,Values=vpc-xxx | awk '{ print $8 }' | sort -n | grep "i-"

我-4115d38c

i-4115d38c

我-5d534697

i-5d534697

我-6e679a45

i-6e679a45

我-7a659851

i-7a659851

我-8d6bae40

i-8d6bae40

我-cd6f9000

i-cd6f9000

我-d264ad1e

i-d264ad1e

我-d5888618

i-d5888618

我-e2332e2e

i-e2332e2e

PS考虑到你已经配置/运行AWS配置

ps considering that you already configured / run "aws configure"

这篇关于如何获取标签EC2-描述-情况下在shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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