How to fix Error: No exported attribute named in Terraform
This error occurs when you reference an attribute that does not exist on a Terraform resource, data source, or module output. Common causes include typos in attribute names, missing .outputs in remote state references, and version incompatibilities.
Quick fix
Fixes Error: No exported attribute named
data.terraform_remote_state.example.my_output- Check the exact attribute name in provider documentation
- For remote state: Use .outputs to access output values
- Clear the Terraform cache after module changes
- For resources with count: Add conditional access syntax
data.terraform_remote_state.example.my_outputError: No exported attribute named
What this error means
Terraform is trying to access an attribute on a resource, data source, or module that is not defined or exported. This happens when you reference an attribute name that does not exist, or when you use incorrect syntax to access nested attributes. The error can also occur when referencing remote state outputs without the required .outputs path, or when using resources configured with count or for_each without the proper index syntax.
Typical symptoms
- terraform plan or terraform apply fails with attribute reference errors
- Error message shows the attribute name you tried to access
- Works with older Terraform versions but fails after upgrading
- Module outputs are not accessible from parent configuration
Common causes
- Typo in the attribute name (e.g., private_ip instead of private_ip_address)
- Missing .outputs in remote state references (Terraform 0.12+)
- Resource attribute does not exist in current provider version
- Attempting to reference resource with count=0 without conditional logic
- Using for_each on a resource but accessing it like a single resource
- Child module does not define the output being referenced
- Stale Terraform module cache with outdated schema information
How to fix "Error: No exported attribute named"
Open the Terraform provider documentation for your resource type and verify the exact spelling and nesting of the attribute you are trying to access. Provider documentation is available at https://developer.hashicorp.com/terraform/language/resources or the specific provider docs (aws, azurerm, google, etc.). Attributes are case-sensitive and must match exactly.
In Terraform 0.12+, when accessing outputs from terraform_remote_state, you must include the .outputs path. Change:
data.terraform_remote_state.example.my_outputTo:
data.terraform_remote_state.example.outputs.my_outputThis is required because outputs are nested under the outputs attribute.
When you modify module variables or outputs, Terraform may use cached schema information. Clear the cache and reinitialize:
rm -rf .terraform
terraform initThen run terraform plan or apply again. This ensures Terraform reads the latest module definitions.
When a resource uses count, you must access specific instances:
aws_instance.example[0].id # Access first instanceFor resources with count=0, use conditional logic:
resource_id = var.create_instance ? aws_instance.example[0].id : nullWithout the index, Terraform treats count resources as lists.
When a resource uses for_each, access specific instances with the key:
aws_instance.example["web"].id # Access instance with key "web"You cannot reference a for_each resource without specifying the key. If you need all instances, use splat syntax:
[for k, v in aws_instance.example : v.id]To expose a resource attribute from a module, define an output block in the module's outputs.tf:
output "instance_id" {
description = "The ID of the instance"
value = aws_instance.example.id
}Then in your parent configuration:
module "compute" {
source = "./modules/compute"
}
output "app_instance_id" {
value = module.compute.instance_id
}Each level must explicitly define the output being referenced.
Advanced notes
When upgrading providers or Terraform versions, attribute names sometimes change or are deprecated. If you get this error after an upgrade, check the provider changelog for breaking changes. Use terraform console to interactively explore available attributes on resources and verify correct syntax before running apply. Some attributes are conditional and only exist when specific configuration blocks are present (e.g., aws_s3_bucket.website_domain only exists when the website block is configured).
Frequently asked questions
- What does "Error: No exported attribute named" mean?
- Terraform is trying to access an attribute on a resource, data source, or module that is not defined or exported. This happens when you reference an attribute name that does not exist, or when you use incorrect syntax to access nested attributes. outputs path, or when using resources configured with count or for_each without the proper index syntax.
- How do I fix "Error: No exported attribute named"?
- This error occurs when you reference an attribute that does not exist on a Terraform resource, data source, or module output. Common causes include typos in attribute names, missing .outputs in remote state references, and version incompatibilities.
- What causes "Error: No exported attribute named"?
- Typo in the attribute name (e.g., private_ip instead of private_ip_address) Missing .outputs in remote state references (Terraform 0.12+) Resource attribute does not exist in current provider version
- Is the "Error: No exported attribute named" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Terraform Official Documentation
- ๐github.com - 21442(GitHub)
- ๐ฌdiscuss.hashicorp.com - 31765(Stack Overflow)