I found a security group with all traffic allowed from 0.0.0.0
and I want to know all the resources that are using this security group.
Is there any AWS CLI command for this or should I go through each resource to see if this security group is attached?
Select you region in which resources are located
Search results show the network interfaces associated with the security group. Check the description of the network interface to determine the resource that's associated with the security group. For example, ELB app/example-alb/1234567890abcdef
indicates that an Application Load Balancer with the name example-alb
is using this security group.
aws ec2 describe-network-interfaces --filters Name=group-id,Values=<group-id> --region <region> --output json
If the output is empty then there are no resources attached for example
{
"NetworkInterfaces": []
}
If you see information in output then run this
aws ec2 describe-network-interfaces \
--filters Name=group-id,Values=<group-id> \
--region <region> --output json \
--query "NetworkInterfaces[*].[NetworkInterfaceId,Description,PrivateIpAddress,VpcId]"