HCL Dynamic Block - for_each - odd behavior when used with an empty set


Trying to have a template defined that can conditionally add additional disks, but only if a value is set in an env var. I tried to use for_each, thinking that if the env var was not set or if the env var value was empty the for_each would not try to loop, but that does not seem to be the case. Instead if loops regardless and throws up an error during build complaining that the value for disk_size must be an integer. Am I doing something wrong?


Hi @pmanno1, could you share some code samples to better understand your approach? As per my understanding it should work using e.g. a default null value to skip creating a resource.