Open vfab opened 4 years ago
I have a similar annoying experience with AWS WAFv2, which changed their resource definitions and instead of being able to set a simple interpolated value for the default action property now we have to define a nested block.
I don't know the syntax which will allow to interpolate the name of the block which could make that simple. In WAFv2 that's 'allow' or 'block'. I've found a workaround but it's ugly. It requires 6 lines (for 2 possible values) instead of 1 interpolated line. What probably was an improvement over how final JSON looks and simplify it a bit resulted in a burden in Terraform code.
Regarding author's enhancement - may be to shorten the syntax even more and to get contents of the blocks directly from the variable?
dynamic site_config {
interpolated_content = var.site_config # or local.site_config
}
1+
I have the same frustrating experience with site_config in Azure function app service. I'd need to assign a dynamic map to the content. The syntax proposed by dvishniakov is an elegant and simple solution. Generally, this seems to be a serious limitation of the block construct. I wonder why there are just a few people tracking this issue.
I would also like this enhancement.
I'm trying to assign in a function_app module all values for site_config defined in variables elsewhere. But it would be nice to just define that block as it is expected and not have to define each property individually in the module.
If some values are not applicable for the version of the provider, sure, just error out.
It's even more difficult when there are nested properties for something like site_config which also has complex objects like application_stack. Internally the provider should just iterate over all properties and assign if possible and error if not possible.
Is there any way to assign the contents of a dynamic block by passing in a single variable that defines its contents? For example, with an Azure App Service there is a site_config block, which has a lot of arguments. I would like to declare a variable named site_config of type
any
and set the contents of the dynamic block to equal my variable. Instead ofI would like to do something like
If this isn't currently possible I think this would be a great enhancement. But if it is possible please share some sample code.
Thanks!