AwsCLI: различия между версиями
Материал из noname.com.ua
Перейти к навигацииПерейти к поискуSirmax (обсуждение | вклад) |
Sirmax (обсуждение | вклад) |
||
(не показано 6 промежуточных версий этого же участника) | |||
Строка 7: | Строка 7: | ||
Сниппеты работы с AWS CLI - шпаргалка |
Сниппеты работы с AWS CLI - шпаргалка |
||
+ | =Вывод в тексте= |
||
<PRE> |
<PRE> |
||
− | aws ec2 describe-instances --query 'Reservations[*].Instances[*].[Placement.AvailabilityZone, State.Name, InstanceId |
+ | aws ec2 describe-instances --query 'Reservations[*].Instances[*].[Placement.AvailabilityZone, State.Name, InstanceId]' |
+ | </PRE> |
||
<PRE> |
<PRE> |
||
+ | ap-southeast-1b running i-0cddd1f1b8d20e34b |
||
+ | ap-southeast-1b running i-0e3450c0c7052f960 |
||
+ | ... |
||
+ | </PRE> |
||
+ | |||
+ | =Пример с таблицей= |
||
+ | <PRE> |
||
+ | aws ec2 describe-instances --query 'Reservations[].Instances[].{Name:Tags[?Key==`Name`]|[0].Value,PublicIP:PublicIpAddress}' --output table |
||
+ | </PRE> |
||
+ | <PRE> |
||
+ | ----------------------------------------------------------------------------------------------- |
||
+ | | DescribeInstances | |
||
+ | +---------------------------------------------------------------------------+-----------------+ |
||
+ | | Name | PublicIP | |
||
+ | +---------------------------------------------------------------------------+-----------------+ |
||
+ | | some-host | 52.0.0.0 | |
||
+ | +---------------------------------------------------------------------------+-----------------+ |
||
+ | </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 |
||
+ | </PRE> |
||
+ | |||
<PRE> |
<PRE> |
||
+ | --------------------------------------------------------------------------------------------------------------------------------- |
||
+ | | DescribeInstances | |
||
+ | +------------------+---------------------------------------------------------------------------+-----------------+--------------+ |
||
+ | | AvailabilityZone | Name | PublicIP | State | |
||
+ | +------------------+---------------------------------------------------------------------------+-----------------+--------------+ |
||
+ | | ap-southeast-1a | opentsdb03_production_v4 | None | running | |
||
+ | +------------------+---------------------------------------------------------------------------+-----------------+--------------+ |
||
</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"