Best way to control whether a query is "skipped" or produces a "pass / fail" #553
-
Hello 👋 , I am trying to create a cnspec query (assertion) for GCP Terraform that checks whether a If the instance block does not have an This should pass...
This should fail ...
right now, the
Should I use an |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hiya! We can avoid that Looking at your current code: terraform.resources
.where( nameLabel == "google_compute_instance") {
blocks.where( type == "network_interface") {
blocks
.where( type == "access_config")
.all( arguments.values.length != 0 )
}
} Now it says: (1) blocks (2) where the type is |
Beta Was this translation helpful? Give feedback.
-
@arlimus I just tried the updated query on a |
Beta Was this translation helpful? Give feedback.
-
@arlimus turns out my version of |
Beta Was this translation helpful? Give feedback.
Hiya! We can avoid that
if
-condition if we use a slightly different check:all
can for example check if all entries in a block satisfy a condition. If the block is empty, all entries will automatically satisfy the condition.Looking at your current code:
Now it says: (1) blocks (2) where the type is
access_config
should (3) all have non-emptyarguments
.