I'm trying to create in output in my Terraform template.
output "port" {
value = "${kubernetes_service.postgres_service.spec}"
}
will produce
ports = {
cluster_ip = 10.245.175.57
external_ips = []
external_name =
load_balancer_ip =
load_balancer_source_ranges = []
port = [map[node_port:30344 protocol:TCP name: port:5432 target_port:5432]]
selector = map[app:postgres]
session_affinity = None
type = NodePort
}
I tried "${kubernetes_service.postgres_service.spec}.port"
but it produces a syntax error.
I also tried "${lookup(kubernetes_service.postgres_service.spec[0], "port")}"
but it can only be used with flat maps.
Am I missing something? This is my first attempt at Terraform and it's a lot different than what I'm used to (CloudFormation). Any help will be greatly appreciated. I'm just looking to get the value of node_port (30344) to output to the screen after running apply.
This should work:
output "port" {
value = "${kubernetes_service.postgres_service.spec.0.port.0.port}"
}
Reference:
resource.TestCheckResourceAttr("kubernetes_service.test", "spec.0.port.0.port", "8080"),