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

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску
 
(не показана 1 промежуточная версия этого же участника)
Строка 45: Строка 45:
 
+------------------+---------------------------------------------------------------------------+-----------------+--------------+
 
+------------------+---------------------------------------------------------------------------+-----------------+--------------+
 
</PRE>
 
</PRE>
  +
  +
  +
  +
aws ec2 describe-instances --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].Ebs.VolumeId[][]'
  +
aws ec2 describe-instances --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].Ebs.VolumeId[][]' --filters "Name=tag:stack,Values=production"
  +
  +
  +
* https://stackoverflow.com/questions/40396536/aws-cli-ec2-describe-instances

Текущая версия на 12:28, 21 августа 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     |
+------------------+---------------------------------------------------------------------------+-----------------+--------------+


aws ec2 describe-instances --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].Ebs.VolumeId[][]' aws ec2 describe-instances --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].Ebs.VolumeId[][]' --filters "Name=tag:stack,Values=production"