I've looked through many other stack overflow questions that are similar, but can't find exactly what I'm looking for. This seems simple, but I cannot get the syntax quite right and I'm tired of throwing spaghetti at the wall. Given this return from the AWS CLI:
{
"IPSet":{
"Description":"",
"Name":"testip",
"IPAddressVersion":"IPV4",
"Id":"a1b2c3d4-5678-90ab-cdef-EXAMPLE1111",
"ARN":"arn:aws:wafv2:us-west-2:123456789012:regional/ipset/testip/a1b2c3d4-5678-90ab-cdef-EXAMPLE1111",
"Addresses":[
"192.0.2.0/16"
]
},
"LockToken":"447e55ac-2396-4c6d-b9f9-86b67c17f8b5"
}
How would use JQ to determine if it contained a certain IP address? This is my closest guess so far, but not quite right.
echo ${single_ip_set} | jq -c '.IPSet.Addresses[] | contains("255.255.255.8")'
single_ip_set is my variable name. This checks every element in the array and gives a response. So does this:
echo ${single_ip_set} | jq -c '.IPSet.Addresses[] | index("255.255.255.8")'
I really just want one final answer as whether or not the array contains one instance. of my requested IP.