쿼리
aws-ec2-security-groups
| explode ingress
| parsemap field=ingress overlay=t
| explode ipv4_ranges
| parsemap field=ipv4_ranges overlay=t
| rename description as item_description
| rex field=cidr_ip "(?<ip>[^/]+)/(?<cidr>\d+)"
| eval cidr = int(cidr)
| fields aws_profile, region, vpc_id, group_id, group_name, cidr_ip, ip, cidr, from_port, to_port, item_description
| # any 또는 B클래스 범위 필터
| search cidr <= 16 or ip == "0.0.0.0"
aws-ec2-security-groups
쿼리 명령어를 이용해서 전체 EC2 보안 그룹 목록 나열explode ingress
를 사용해서 ingress 배열 목록을 레코드로 펼침parsemap field=ingress overlay=t
으로 ingress 내부의 키/값을 필드로 펼침explode ipv4_ranges
를 사용해서 모든 범위 목록을 레코드로 펼침- cidr_ip 값을
/
기준으로 IP 주소 필드(ip)와 CIDR 필드(cidr)로 분리 eval cidr = int(cidr)
으로 cidr 문자열을 정수로 타입 변환- B클래스 이상(
cidr <= 16
) 이거나 any (0.0.0.0
) 인 경우를 필터링
이 상태에서 만약 보안 그룹 ID, 이름의 목록만 추출하고 싶다면 아래 명령어를 추가합니다.
| stats count by group_id, group_name
| fields group_id, group_name