AwsCLI: различия между версиями

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску
Строка 34: Строка 34:
 
<PRE>
 
<PRE>
 
aws ec2 describe-instances --query 'Reservations[].Instances[].{Name:Tags[?Key==`Name`]|[0].Value,PublicIP:PublicIpAddress, AvailabilityZone:Placement.AvailabilityZone, State:State.Name}' --output table
 
aws ec2 describe-instances --query 'Reservations[].Instances[].{Name:Tags[?Key==`Name`]|[0].Value,PublicIP:PublicIpAddress, AvailabilityZone:Placement.AvailabilityZone, State:State.Name}' --output table
  +
</PRE>
  +
  +
<PRE>
  +
---------------------------------------------------------------------------------------------------------------------------------
  +
| DescribeInstances |
  +
+------------------+---------------------------------------------------------------------------+-----------------+--------------+
  +
| AvailabilityZone | Name | PublicIP | State |
  +
+------------------+---------------------------------------------------------------------------+-----------------+--------------+
  +
| ap-southeast-1a | opentsdb03_production_v4 | None | running |
  +
+------------------+---------------------------------------------------------------------------+-----------------+--------------+
 
</PRE>
 
</PRE>

Версия 12:02, 19 августа 2021


AWS CLI

Сниппеты работы с AWS CLI - шпаргалка

Вывод в тексте

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[Placement.AvailabilityZone, State.Name, InstanceId]'
ap-southeast-1b	running	i-0cddd1f1b8d20e34b
ap-southeast-1b	running	i-0e3450c0c7052f960
...

Пример с таблицей

aws ec2 describe-instances --query 'Reservations[].Instances[].{Name:Tags[?Key==`Name`]|[0].Value,PublicIP:PublicIpAddress}' --output table
-----------------------------------------------------------------------------------------------
|                                      DescribeInstances                                      |
+---------------------------------------------------------------------------+-----------------+
|                                   Name                                    |    PublicIP     |
+---------------------------------------------------------------------------+-----------------+
|  some-host                                                                |  52.0.0.0       |
+---------------------------------------------------------------------------+-----------------+

Еще пример с выводом таблицы

aws ec2 describe-instances --query 'Reservations[].Instances[].{Name:Tags[?Key==`Name`]|[0].Value,PublicIP:PublicIpAddress, AvailabilityZone:Placement.AvailabilityZone, State:State.Name}' --output table
---------------------------------------------------------------------------------------------------------------------------------
|                                                       DescribeInstances                                                       |
+------------------+---------------------------------------------------------------------------+-----------------+--------------+
| AvailabilityZone |                                   Name                                    |    PublicIP     |    State     |
+------------------+---------------------------------------------------------------------------+-----------------+--------------+
|  ap-southeast-1a |  opentsdb03_production_v4                                                 |  None           |  running     |
+------------------+---------------------------------------------------------------------------+-----------------+--------------+