How to handle vars that may not be set?

I have values I want to pass to AMI tags and Ansible builder that only apply in certain situations. Is it possible to set a run_tags only when a certain value has been set? If I just set an input variable to a blank string "", I get a tag with a key and empty value. I’d rather no key if there is no value passed in.

IE, for tag like AppVersion = latest, If I pass -var AppVersion=latest, I want there to be an AMI tag, but if I don’t pass it in, I don’t want there to be any AppVersion tag at all.

I fell like I’m over thinking it but I can’t solve.