Skip to content

Default (optional) values in nested null object cause it to be non-null #32160

@slwbuild

Description

@slwbuild

Terraform Version

Terraform v1.3.4

Terraform Configuration Files

module "defaulting_module" {
    source = "./modules/default-module"
    request = {}
}

output "output" {
    value = module.defaulting_module
}
variable "request" {
    type = object({
        thing = optional(object({
            flag = optional(bool, false)
        }))
    })
}

output "request" {
    value = var.request
}

Debug Output

Changes to Outputs:
  + output = {
      + request = {
          + thing = {
              + flag = false
            }
        }
    }

Expected Behavior

thing should be null

Actual Behavior

thing is non-null and contains defaulted values

Steps to Reproduce

terraform plan

Additional Context

Output in TF 1.3.3 matched expected results. Changed in 1.3.4

References

No response

Metadata

Metadata

Assignees

Labels

bugconfigconfirmeda Terraform Core team member has reproduced this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions