I’ve tried to wrap the two objects in a jsonencode function but it won’t work either: The given value is not suitable for child module variable "log_configuration" defined at
The use case looks common to me (decide to either pass a null kind of value or not depending on other configuration) but I don’t understand how I’m supposed to achieve that.
Without seeing your module code, I can’t be certain of the right solution here. Can you share more about your module, the source of this configuration, and what you’re trying to achieve?
In Terraform, there is no type which is equivalent to an arbitrary nested structure (e.g. a Ruby hash, a Python dict, or a JavaScript object). Instead, we have the object type, which is more akin to a struct in languages like C, Go, or Rust.
Any two object values of the same type must have the same attribute names and types. An empty object can only be substituted for another empty object, and cannot be used in place of an object with attributes.
The null value for any given object type is null. You can change your code to pass null instead of the full object, and it should work:
If you do this, your module will have to be updated to cope with a null value for the log_configuration value. How to do that depends on how the configuration is used in the module.
It’s possible that your use case might be met by the optional attributes experiment, combined with the defaults function. To be able to suggest how to do that, I’d need to know more about your entire configuration—it’s not a drop-in solution for this exact block of code.