如何通过EC2的AWS CLI获取所有安全组以显示在表中 [英] How to get all security groups through AWS CLI of an EC2 to show in a table
问题描述
我正在尝试显示所有实例以及附加的安全组,阻止设备名称及其deleteontermination状态.我需要以表格格式显示此数据,但我不断收到以下错误.
I am trying to show all instances along with attached security groups, block device name and their deleteontermination status. I need to show this data in table format but I am continuously getting the below error.
请帮助我了解我在这里缺少什么.
Kindly help me to understand what I am missing here.
PR-MacBook-Pro:~ pr$ aws ec2 describe-instances --output table --query 'Reservations[*].Instances[*].[InstanceId,SecurityGroups[].GroupName,Placement.AvailabilityZone,BlockDeviceMappings[].DeviceName, BlockDeviceMappings[].Ebs.DeleteOnTermination]'
Row should have 1 elements, instead it has 2
PR-MacBook-Pro:~ pr$
推荐答案
我在Google搜索时遇到了这个问题.
I came across this while searching in google.
经过一些研究,我发现您必须使用 |join(`,`,@)
After I did a bit of research I found that you have to use | join(`, `, @)
所以命令将是
aws ec2 describe-instances --output table --query'Reservations [*].Instances [*].[InstanceId,SecurityGroups [].GroupName |join(`,`,@),Placement.AvailabilityZone,BlockDeviceMappings [].DeviceName |join(`,`,@),BlockDeviceMappings [].Ebs.DeleteOnTermination |join(`,`,to_array(to_string(@)))]'
这篇关于如何通过EC2的AWS CLI获取所有安全组以显示在表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!