Seems these days you can also use try to check if something is set.
try(var.env, false)
After that your code will work since var.env is now defined with the value false even if var.env was never defined somewhere.
https://www.terraform.io/docs/configuration/functions/try.html