Hello @lukasmrtvy,
Did you figure this out? I have a very similar need. I am investigating using dynamic blocks so I can specify whether I am using my custom image or one from the marketplace (https://www.terraform.io/docs/configuration/expressions.html#dynamic-blocks)
Thanks