Skip to content

Terraform resource query matching an argument and a block #540

Closed Answered by arlimus
scottford-io asked this question in Q&A
Discussion options

You must be logged in to vote

Awesome question, let's pick it apart:

First, you have the part where you are looking for the firewall statement, which you already wrote down:

terraform.resources
  .where( nameLabel == "google_compute_firewall" )

Next comes another filter, because you only care about elements that have the source_ranges set:

terraform.resources
  .where( nameLabel == "google_compute_firewall" )
  .where( arguments['source_ranges'].contains("0.0.0.0/0") )

(you could even check for specific subranges and more ;) )

Finally, we want to say that none of these resources have allow-blocks configured

terraform.resources
  .where( nameLabel == "google_compute_firewall" )
  .where( arguments['source_ranges'].cont…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by scottford-io
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants