Skip to content

Commit

Permalink
Merge pull request #11 from isovalent/add-external-ips
Browse files Browse the repository at this point in the history
Add external ips
  • Loading branch information
darox authored Oct 10, 2023
2 parents 48a9344 + 91e5bab commit b6ee303
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,13 @@ resource "null_resource" "kubeconfig" {
}
}
}

data "external" "external_ips" {
program = ["bash", "-c", "gcloud compute instances list --filter=\"name~${var.name}\" --format=\"json(networkInterfaces[0].accessConfigs[0].natIP)\" | jq 'to_entries | map({key: (.key|tostring), value: (.value|tostring)}) | from_entries'"]
}

locals {
external_ips = [
for value in data.external.external_ips.result : jsondecode(value).networkInterfaces[0].accessConfigs[0].natIP
]
}
7 changes: 6 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

output "external_ips" {
value = local.external_ips
description = "External IPs of the nodes"
}

output "id" {
value = module.main.cluster_id
}
Expand All @@ -21,5 +26,5 @@ output "path_to_kubeconfig_file" {
}

output "zones" {
value = "module.main.zones"
value = module.main.zones
}

0 comments on commit b6ee303

Please sign in to comment.