Terraform Version
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
Terraform Version
Terraform Configuration Files
variables file
tfvars file
tf file
Debug Output
Crash Output
Expected Behavior
terraform should resolve variables similarly in
importas inplanActual Behavior
terraform
initandplanwork successfully, butimportyields the following: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
defaultin the module'svariables.tffile 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