Skip HCL block labels using the tilde (~) operator
mainHCL blocks often have multiple labels (e.g., resource "aws_instance" "main"). Normally, you must traverse each label individually: resource.aws_instance.main.
To skip all name labels and go directly to the block body, append a tilde (~) to the segment. This is useful for querying all blocks of a certain type regardless of their specific names or labels.
Examples:
# Without ~: must name every label
hq 'resource.aws_instance.main.ami' main.tf
# With ~: skip all labels, access body directly
hq 'resource~.ami' main.tf
# All resource blocks regardless of labels
hq 'resource~[*]' main.tf
# Filter blocks by body content
hq 'resource~[select(.ami)]' main.tfhq 'resource~.ami' main.tf
hq 'resource~[*]' main.tf
hq 'resource~[select(.ami)]' main.tf