civo/terraform-provider-civo

[FEATURE] add datasource for civo_kubernetes_clusters

Opened this issue · 4 comments

Description

I would like to be able to access information about Kubernetes clusters in a given region to help with dynamic configuration. Right now we have civo_kubernetes_cluster, but it requires foreknowledge of a specific cluster's name.

Screenshots

No response

Additional information

No response

Do you have an example of your idea ??, maybe that can help the team to take a decision

Sure! I was thinking something like this (untested, probably some invalid HCL, but hopefully the point gets across):

locals {
  cluster_endpoints = {
    for cluster in data.civo_kubernetes_clusters.nyc1.results :
    cluster.name => cluster.api_endpoint
  }
}

data "civo_kubernetes_clusters" "nyc1" {
  region = "NYC1"
}

I want to use this to dynamically update our monitoring stack to include all clusters we may have.

So, your idea is to have a data source to get all the clusters in a region, and then use that to populate your system. Is that ??

That is correct. The immediate use case I had in mind when I created this ticket is using the data source to iterate over all clusters in a region to update a configuration file for a monitoring platform. The main goal being to have periodic checks whether the respective API endpoints are accessible.