I am trying to do a filter using aws query to output 0.0.0.0/0 Ips and find which ports they are coming from however when I do
aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values='0.0.0.0/0' --query "SecurityGroups[*].{GN:GroupName,Ports: IpPermissions.FromPorts}" --output json
In the Ports column, it outputs None, since it is not finding that filter and when I do
aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values='0.0.0.0/0' --query "SecurityGroups[*].{GN:GroupName,Ports: IpPermissions}" --output json
I get all the Ip Ranges when I only want 0.0.0.0/0 and which Port that Open Ip is coming from (FromPort and ToPort ). And I don't want to do a filter just for a certain Port because I want to see what port each open Ip is coming from.
I am not sure why this is not working since the IpPermissions.ToPort and IpPermissions.FromPort are both a filter of aws security groups.
You need two modification in the query
FromPort
not FromPort
IpPermissions[].FromPort
aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values='0.0.0.0/0' \
--query "SecurityGroups[*].{GN:GroupName,Ports: IpPermissions[].FromPort}" --output json
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.