civo / terraform-provider-civo

Terraform Civo provider
https://www.civo.com
Mozilla Public License 2.0
66 stars 51 forks source link

[FEATURE] add datasource for civo_kubernetes_clusters #183

Open codekoala opened 1 year ago

codekoala commented 1 year ago

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

alejandrojnm commented 1 year ago

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

codekoala commented 1 year ago

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.

alejandrojnm commented 1 year ago

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 ??

codekoala commented 1 year ago

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.