来自AWS命令行的EC2实例 [英] EC2 instance from AWS command line

查看:91
本文介绍了来自AWS命令行的EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对AWS非常陌生.我有一个Windows实例正在运行,并配置了我的aws命令行.我已经阅读了AWS文档,但似乎找不到我想要的东西.

I am very new to AWS. I've got a Windows instance running and have my aws command line configured. I've read through the AWS docs but can't seem to find exactly what I'm looking for.

如何从命令行查看当前实例?

How do I view my current instances from the command line?

推荐答案

如Rodrigo M的答案所述,您应该使用describe-instances查看您的EC2实例.通常,help命令是浏览CLI的最佳方法.从aws ec2 help开始,然后尝试各种选项.您还可以通过aws ec2 describe-instances help来获得有关子命令的更多详细信息.

As noted in the answer by Rodrigo M, you should use describe-instances to view your EC2 instances. In general, the help command is the best way to explore the CLI. Start with aws ec2 help and try the various options. You can get more details on subcommands with aws ec2 describe-instances help as well.

输出有点冗长,默认情况下为JSON.如果不进行额外的处理,这可能会让人有些不知所措并且难以阅读.如果您打算交互使用CLI,我建议您熟悉--query aws CLI参数.

The output is a bit verbose and by default in JSON. This can be a bit overwhelming and hard to read without additional processing. I'd recommend getting familiar with the --query aws CLI parameter if you intend to use the CLI interactively.

尤其是,我使用它来快速概述我的EC2实例:

In particular, I use this for a quick overview of my EC2 instances:

aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId, Tags[?Key==`Name`] | [0].Value, State.Name, PublicDnsName]' --output table

要检查实例上的一个特定属性,请执行以下操作:

To check one particular attribute on an instance:

aws ec2 describe-instances --query Reservations[0].Instances[0].InstanceType --output text --instance-ids <my-instance-id>

一旦您习惯了学习命令和管理输出,CLI就会非常强大.此外,由于aws CLI命令通常与API调用一对一映射,因此它对于学习语法API也很有帮助.

The CLI is very powerful once you get comfortable with learning the commands and managing the output. It's also helpful for learning the porgramming APIs as well, since aws CLI commands generally map one-to-one with an API call.

这篇关于来自AWS命令行的EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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