如何通过命令行获取亚马逊地区列表?


13

我想看看如何在命令行上从AWS中获取区域列表,以便快速查找内容,该怎么做?

Answers:


10

您可以通过从命令行运行ec2-describe-regions命令(如果您已安装multiverse中的ec2-api-tools)来执行此操作。

$ ec2-describe-regions
REGION  eu-west-1   ec2.eu-west-1.amazonaws.com
REGION  sa-east-1   ec2.sa-east-1.amazonaws.com
REGION  us-east-1   ec2.us-east-1.amazonaws.com
REGION  ap-northeast-1  ec2.ap-northeast-1.amazonaws.com
REGION  us-west-2   ec2.us-west-2.amazonaws.com
REGION  us-west-1   ec2.us-west-1.amazonaws.com
REGION  ap-southeast-1  ec2.ap-southeast-1.amazonaws.com

是的。您需要配置一个默认区域,然后该区域才能起作用(3年后还是?)。所以Google是你的朋友。区域和终点(rande-恶名叫randy)在docs.aws.amazon.com/general/latest/gr/rande.html。为什么在配置超出我的权限之前尝试将它们默认为us-east-1呢?
mckenzm '16

@mckenzm笑“兰德- mnemonically兰迪”我认为这只是一些内部发生我的头。Google可能会对我搜索“ amazon rande”的次数感到开怀大笑。我认为不使用默认终结点的原因是,这将给单个区域的终结点增加很多负担,并且对于接近另一区域的大部分用户而言,不必要的速度会变慢。它也可能与aws-cli内部的逻辑流程有关-也许“ ec2”部分需要在实际理解“描述区域”之前进行端点选择。疯狂的猜测。
Michael-sqlbot

10

现在,这就是您使用aws cli的方式:

$ aws ec2 describe-regions --output table
----------------------------------------------------------
|                     DescribeRegions                    |
+--------------------------------------------------------+
||                        Regions                       ||
|+-----------------------------------+------------------+|
||             Endpoint              |   RegionName     ||
|+-----------------------------------+------------------+|
||  ec2.eu-west-1.amazonaws.com      |  eu-west-1       ||
||  ec2.ap-southeast-1.amazonaws.com |  ap-southeast-1  ||
||  ec2.ap-southeast-2.amazonaws.com |  ap-southeast-2  ||
||  ec2.eu-central-1.amazonaws.com   |  eu-central-1    ||
||  ec2.ap-northeast-2.amazonaws.com |  ap-northeast-2  ||
||  ec2.ap-northeast-1.amazonaws.com |  ap-northeast-1  ||
||  ec2.us-east-1.amazonaws.com      |  us-east-1       ||
||  ec2.sa-east-1.amazonaws.com      |  sa-east-1       ||
||  ec2.us-west-1.amazonaws.com      |  us-west-1       ||
||  ec2.us-west-2.amazonaws.com      |  us-west-2       ||
|+-----------------------------------+------------------+|
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.