Difference between revisions of "Cannot iterate over null"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
  
  
[[aws ec2 describe-instances]] --query 'Reservations[*].Instances[?not_null(PublicIpAddress)]' | jq -r '.[][]|.PublicIpAddress+" "+(.Tags[]|select(.Key=="Name").Value)'
+
 
  
 
  [[jq]]: error (at <stdin>:1904): Cannot iterate over [[null]] (null)
 
  [[jq]]: error (at <stdin>:1904): Cannot iterate over [[null]] (null)
 +
 +
[[aws ec2 describe-instances]] --query 'Reservations[*].Instances[?not_null(PublicIpAddress)]' | jq -r '.[][]|.PublicIpAddress+" "+(.Tags[]|select(.Key=="Name").Value)'
 +
 +
Remove Tags filter to avoid list of IPs to be truncated and get full list:
 +
[[aws ec2 describe-instances]] --query 'Reservations[*].Instances[?not_null(PublicIpAddress)]' | jq -r '.[][].PublicIpAddress'
  
  

Revision as of 08:35, 23 June 2022



jq: error (at <stdin>:1904): Cannot iterate over null (null)

aws ec2 describe-instances --query 'Reservations[*].Instances[?not_null(PublicIpAddress)]' | jq -r '.[][]|.PublicIpAddress+" "+(.Tags[]|select(.Key=="Name").Value)'

Remove Tags filter to avoid list of IPs to be truncated and get full list:
aws ec2 describe-instances --query 'Reservations[*].Instances[?not_null(PublicIpAddress)]' | jq -r '.[][].PublicIpAddress'


See also

Advertising: