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 |
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 |
|
@arlimus I just tried the updated query on a |
|
@arlimus turns out my version of |


Hiya! We can avoid that
if-condition if we use a slightly different check:allcan 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_configshould (3) all have non-emptyarguments.