AWS CLI-AWS ec2 describe-instances为每个EC2实例检索密钥对mame [英] AWS CLI - aws ec2 describe-instances to retrieve keypair mame for each EC2 instance

查看:136
本文介绍了AWS CLI-AWS ec2 describe-instances为每个EC2实例检索密钥对mame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查询附加到每个EC2实例的密钥对名称,下面的ec2 describe-instances可以正常工作,它完全满足我的需要,但是{keypair.Name}下的列显示[NONE]我是不知道我是否使用正确的参数名称-我知道在登录控制台时,EC2实例上附加的keypairNames.epm很少,但是在我通过以下命令运行的报告中却没有看到.非常感谢任何输入.

I am trying to query keypair names that are attached to each EC2 instance, the ec2 describe-instances below works fine, it does exactly what I need, but the column under the {keypair.Name} displays [NONE] I am not sure if I am using the proper parameter name - I know there are few keypairNames.epm attached on my EC2 instances when I login to the console, but I am not seeing that on my report that I run by the command below. Any input is much appreciated.. Thx !

aws ec2 describe-instances --filters Name=instance-state-name,Values=running --query 'Reservations[].Instances[].[Tags[?Key==`Name`].Value | [0],InstanceId,Platform,State.Name,PrivateIpAddress,PublicIpAddress,InstanceType,PublicDnsName,keypair.Name]' --output table --region us-west-2

推荐答案

出于某些原因,我执行以下操作

I do the following for a few reasons

  • 可以很容易地通过管道传输到grep
  • 如果您想改善数据,则无需重复查询aws api
  • 我通常会遍历多个区域,因此可以轻松浏览所有区域(和帐户)
instances=`aws ec2 describe-instances `
echo $instances | jq '.Reservations[].Instances[] | "[\(.InstanceId) \(.Platform) \(.State.Name) \(.PrivateIpAddress) \(.PublicIpAddress) \(.InstanceType) \(.PublicDnsName) \(.KeyName)]"'

这篇关于AWS CLI-AWS ec2 describe-instances为每个EC2实例检索密钥对mame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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