Is there any way to prevent a block from executing if a condition is not satisfied

Hi,

You might want to try try (https://www.terraform.io/docs/language/functions/try.html) or filter a map or list when looping over them on a resource / block creation.
I have recently provided an example to filter a map that could be useful.
See https://discuss.hashicorp.com/t/conditionally-create-resources-when-a-for-each-loop-is-involved/20841/3

Cheers,