Error: Unsupported argument
on XXX line YY, in resource "google_storage_bucket" "default":
13: website = var.bucket_website
An argument named "website" is not expected here. Did you mean to define a
block of type "website"?
The question: What’s the right syntax? Must use a dynamic? Lookup?
A dynamic block would only be necessary here if the decision about whether or not to include the website block must be made dynamically. For example, you might allow var.bucket_website to be null in order to disable the website functionality altogether:
The var.bucket_website[*] syntax is a special mode of the splat operator [*] when applied to a non-list value: if var.bucket_website is null then it will produce an empty list, and otherwise it will produce a single-element list containing the value. We can use that to concisely adapt a variable that is either null or not into what the dynamic block expects: a list with zero or more elements.
I also long to write my code with syntax @JulienBreux suggests.
Although I understand these syntax that you recommend, I think that is lengthy…
could you tell me whether you are considering to equip JulienBreux’s syntax to Terraform?
There are no plans to support treating a nested block type as if it were an argument, if that’s what you mean.
What is likely to improve in future is that a next-generation provider SDK to allow provider authors to make better use of the new data types and associated syntax that Terraform 0.12 introduced, so that they can for example define an argument as being a list of objects as can be done by module authors with variables of type list(object), in which case the syntax for using such things would be the same as passing a list of objects to a module. It’ll be up to each provider to decide which of the models is most appropriate for the underlying system they are writing a provider for, which includes whether the concept in question is modelled as a value of some other object or whether it’s a distinct object in its own right.
I’m not working directly on that project so I don’t have more details to share about that right now, but the technical research is underway right now.