Skip to content

unexpected "Error: Unsupported attribute" for type "any" variable import (0.12.29/0.13.0) #25888

@tony-kerz

Description

@tony-kerz

Terraform Version

v0.12.29 and v0.13.0

Terraform Configuration Files

variables file

variable "rt53" {
  type    = any
  default = {}
}

tfvars file

rt53 = {
  local = {
    private_zone_name = null
  }
}

tf file

locals {
  rt53 = {
    is_local = (var.rt53.local.private_zone_name == null) ? 0 : 1
  }
}

Debug Output

Crash Output

Expected Behavior

terraform should resolve variables similarly in import as in plan

Actual Behavior

terraform init and plan work successfully, but import yields the following:

terraform import -var-file=tfvars/lab.tfvars module.vpc.aws_vpc.this vpc-04d88d30de2b4c0ad
Error: Unsupported attribute

  on module/vpc/rt53.tf line 3, in locals:
   3:     is_local = (var.rt53.local.private_zone_name == null) ? 0 : 1
    |----------------
    | var.rt53 is object with no attributes

This object does not have an attribute named "local".

Steps to Reproduce

i could not easily reproduce in a small application, so there must be some nuance with my larger project.

i did notice that adding the variable values as the default in the module's variables.tf file brute-forced them into the context and it side-stepped the errors...

Additional Context

the item i was trying to import was not directly related to the item mentioned in the errors

References

seems similar to #16139

Metadata

Metadata

Assignees

Labels

bugexplaineda Terraform Core team member has described the root cause of this issue in code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions