Default values for list of objects


Is there any way to define default values for ‘list of objects’ in Terraform 1.0.0 version?. For example, I want to make the TTL attribute ‘optional’ and set the TTL value to ‘60’ for all the objects. And if the user provides a TTL value it must override the default value.

variable “route53_configuration” {
type = list(object({
record_name = string
ttl = optional(number)
tags = optional(map(string))

Thanks in advance.

I have not tested this, but you can try an approach like below:

locals {
  merged_list = [for k,v in var.route53_configuration: k => 60  if k == 'ttl' and v == ""]

I assume user shall be passing only record_name and not ttl is it?