Closed dmikalova closed 2 years ago
Hi, we recently released the Terraform v1.3 alpha, which includes the ability to mark object type attributes as optional and set default values.
I'm following up with issues that have provided feedback on the previous experiment, and wanted to invite you all to try the alpha and provide any feedback on this updated design. You can learn more/add comments here. Thank you so much in advance, and hope you like the feature!
Hello again! Thanks for the bug report.
The final incarnation of the optional attributes feature does not include this defaults
function at all, and instead the facility to choose default values is included in the main type constraint syntax. The partial example shown in the issue comment could therefore now be rewritten like this:
variable "conf" {
...
webhooks = object({
middlewares = list(map(string))
subdomain = optional(string, "webhooks")
})
})
}
The built-in default value handling is implemented in a different way to the defaults
function and so it doesn't include the codepath that crashed here. If anyone sees something similar to this with the final version of the feature, please open a new issue to describe it because we'll need to start over with a new reproduction case against the new codepath.
Thanks!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Version
Terraform Configuration Files
Note that in webhooks, subdomain is optional and middlewares is type list(map(string) and is not optional. If subdomain is provided in defaults, but not middlewares, a panic results. If middlewares is provided in defaults, or the type for middlewares is string, then no panic occurs.
Expected Behavior
Defaults should fill the value for subdomain.
Actual Behavior
An error occurs:
Steps to Reproduce
I haven't tested a minimal reproduction, but you should be able to use the above. Here's the full config as well as the calling terragrunt module.