Is there an alternative for dynamic block?

Hi,

I want to create a VM with additional disk, which I will give disk size in tfvars file. What I want is, this additional disk to be created if I give disk size for it. Otherwise not.

“dynamic block” looks fine for this but it requires for_each from my understanding and with the parameter “additional disk size” i give, it fails as I am using integer for for_each where it needs an iterable collection.

Is there any other way to do this?

Hi @canbahadir,

Would you mind sharing the configuration you tried already and the exact error message Terraform returned when you tried it? That’ll hopefully make it easier to understand your goals and give some suggestions.