Output variables not showing

2,252 views
Skip to first unread message

Franck Ratier

unread,
Jun 22, 2016, 5:41:41 PM6/22/16
to Terraform
Hello!

I wrote a module to setup static websites on AWS and I'd expect it to spit out the name servers from the aws_route53_delegation_set resource.

Everything is applied correctly except that no output is printed. It's no big deal and I can just grep the values in the state file but I don't understand why this doesn't work :/

The module is here.

Cheers,

Franck

Clint Shryock

unread,
Jun 29, 2016, 10:36:20 AM6/29/16
to terrafo...@googlegroups.com
Hey Franck –

I took a look at the module you linked too and I didn't see any outputs declared, am I missing something?

Output docs are here:


You can checkout our Best Practices repo to see an example of what I mean here, at the bottom of this file for example:


Regards,
Clint

Download our latest free guide here

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/c613b024-fd20-4730-97cd-744e9b136779%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Clint

Franck Ratier

unread,
Jun 30, 2016, 2:37:58 AM6/30/16
to Terraform
Hi Clint,

Thanks for your reply.

I do have outputs (they were in variables.tf, I moved them to outputs.tf):

output "NS0" {
  value
= "${aws_route53_delegation_set.main.name_servers.0}"
}
output
"NS1" {
  value
= "${aws_route53_delegation_set.main.name_servers.1}"
}
output
"NS2" {
  value
= "${aws_route53_delegation_set.main.name_servers.2}"
}
output
"NS3" {
  value
= "${aws_route53_delegation_set.main.name_servers.3}"
}


If I apply again I still get no outputs, and explicitly asking for them returns:

The state file has no outputs defined. Define an output
in your configuration with the `output` directive and re-run
`terraform apply` for it to become available.


But in terraform.state I can see:

                "aws_route53_delegation_set.main": {
                   
"type": "aws_route53_delegation_set",
                   
"primary": {
                       
"id": "N8BY9TYOV8VZT",
                       
"attributes": {
                           
"id": "N8BY9TYOV8VZT",
                           
"name_servers.#": "4",
                           
"name_servers.0": "ns-1494.awsdns-58.org",
                           
"name_servers.1": "ns-1548.awsdns-01.co.uk",
                           
"name_servers.2": "ns-433.awsdns-54.com",
                           
"name_servers.3": "ns-716.awsdns-25.net",
                           
"reference_name": "Static Websites"
                       
}
                   
}
               
},


Maybe I'm just missing something obvious or maybe it's related to the fact that the config didn't apply properly the first time I ran it: I applied it and it complained about a bug. I didn't fill in a bug report because it finished apply the second time I ran it... My bad, but I saved the debug output so I'll fill in a bug report later on.

Franck

Clint Shryock

unread,
Jun 30, 2016, 11:30:50 AM6/30/16
to terrafo...@googlegroups.com
Ah, so, the Module has outputs that are defined and those can be consumed by the configs that are using that module, but I don't believe it's expected that they are literally output on the command line. They are "output" to whatever is consuming the module. 

If you wanted to show them on the terminal, you'd need an additional output in whatever config is using the module. To use your example from https://github.com/KifBV/aws-terraform-static-website, in a file that uses that module:


```
output "mod_ns0" {
value = "${module.aws-terraform-static-website.NS0}"
}
```

Does that work?


Regards,
Clint

venura kahawala

unread,
Mar 12, 2019, 10:45:13 PM3/12/19
to Terraform
Thank you very much for this answer. It still helped me today in 2019 :D
Reply all
Reply to author
Forward
0 new messages