Closed TLINDEN closed 4 months ago
Hey @TLINDEN,
the for .. in ..
expression you currently have only works when hcloud_server.web
was a list of servers with count
or for_each
.
To fix your output, try this instead:
output "web_servers_status" {
value = server.status
}
Hope this answered your question. I will close the issue but feel free to respond if you still have problems.
Many thanks for the fast reply!
Ok, I understand, that since I only have 1 server defined, I can't loop. But I can't access the one server either. With your variant config of the output I get:
│ Error: Reference to undeclared resource
│
│ on outputs.tf line 2, in output "web_servers_status":
│ 2: value = server.status
│
│ A managed resource "server" "status" has not been declared in the root module.
So I changed it to "web":
output "web_servers_status" {
value = web.status
}
but the response is the same:
╷
│ Error: Reference to undeclared resource
│
│ on outputs.tf line 2, in output "web_servers_status":
│ 2: value = web.status
│
│ A managed resource "web" "status" has not been declared in the root module.
Ok, I need to do it like so:
output "web_servers_status" {
description = "Status"
value = hcloud_server.web.status
}
:facepalm: Sorry, too early for writing code. Yes, you need to reference the full path including the resource type and the name, aka hcloud_server.web.status
. Sorry for that confusion.
Howdy,
I followed the tutorial on https://community.hetzner.com/tutorials/howto-hcloud-terraform and I have a server up and running:
However, output isn't working. When I add:
I get these errors:
Here's the web server definition:
Versions used: