civo/terraform-provider-civo

Cluster tags shouldn't be saved in comma separated format

zulh-civo opened this issue · 0 comments

Assumming we have created a cluster using this config file:

# Query xsmall instance size
data "civo_instances_size" "xsmall" {
    filter {
        key = "type"
        values = ["kubernetes"]
    }

    sort {
        key = "ram"
        direction = "asc"
    }
}

# Create a cluster
resource "civo_kubernetes_cluster" "my-cluster" {
    name = "my-cluster"
    applications = "Portainer,Linkerd:Linkerd & Jaeger"
    num_target_nodes = 2
    target_nodes_size = element(data.civo_instances_size.xsmall.sizes, 0).name
    tags = "first second"
}

When we rerun terraform apply command, it shows:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # civo_kubernetes_cluster.my-cluster will be updated in-place
  ~ resource "civo_kubernetes_cluster" "my-cluster" {
        id                     = "c0557d11-c1a8-4e27-b52d-cb09be293255"
        name                   = "my-cluster"
      ~ tags                   = "first, second" -> "first second"
        # (16 unchanged attributes hidden)
    }

Terraform think we changed the tags because we joined them using comma — but it supposed to be space separated, not comma separated.

To fix, we need to remove the strings.Join() and save the tags in space separated format. Just like how we defined in in Terraform docs and API docs.