Is it possible to automatically generate terraform variables based on possible arguments?

I am creating a terraform template for an aws rds cluster (Terraform Registry)

I wish to have all possible arguments supplied as variables - an RDS cluster has over 40 possible arguments. Is there a method I can use to automatically generate these arguments as variables rather than manually typing?

No, Terraform doesn’t have any way to introspect the available arguments to a resource and loop over them, within its own syntax.

You said template… but did you mean module? Templates are used to generate text, not to configure Terraform resources. (It doesn’t change the overall answer though.)

Hi @andre.pilakis,

If you are intending to directly expose all of the arguments of a particular resource type anyway, I would typically recommend against writing a module like this. It’s more straightforward to use the resource type directly in that case, without a wrapping module. You can write other modules that take relevant attributes of that resource as input variables if you need some other objects that make use of it.

When writing a module that wraps a particular resource type the usual reason to do that is to represent an opinionated configuration for that resource type so that users of the module will provide far fewer settings than they would if using the resource type directly. That sort of module would therefore only declare a small set of higher-level input variables and then internally derive the resource arguments from those using expressions.

For these reasons, there is no built-in way to generate a “wrapper module” of the kind you are describing, although it is possible in principle to use the provider schema with some custom software to do that if you wish; I think there’s at least one community project which does this, but I’m afraid I don’t recall its name at the moment.