buildkite / terraform-provider-buildkite

Terraform provider for Buildkite
https://registry.terraform.io/providers/buildkite/buildkite/latest
MIT License
56 stars 35 forks source link

SUP-2495: Update Resources to be replaced if Cluster ID changes #554

Closed tomowatt closed 3 months ago

tomowatt commented 3 months ago

Agent Tokens and (Default) Queues cannot be moved between Clusters so any attempt via Terraform should force the Resources to be replaced if the Cluster ID changes.

tomowatt commented 3 months ago

This provides an initial fix for: https://github.com/buildkite/terraform-provider-buildkite/issues/553

tomowatt commented 3 months ago

Manual testing with the following setup:

resource "buildkite_cluster" "primary" {
  name        = "Primary cluster"
  description = "Runs the monolith build and deploy"
}

resource "buildkite_cluster" "secondary" {
  name        = "Secondary cluster"
  description = "Runs the 2nd monolith build and deploy"
}

resource "buildkite_cluster_queue" "default" {
  cluster_id = buildkite_cluster.primary.id
  key        = "default"
}

resource "buildkite_cluster_default_queue" "primary" {
  cluster_id = buildkite_cluster.primary.id
  queue_id   = buildkite_cluster_queue.default.id
}

resource "buildkite_cluster_agent_token" "default" {
  description = "Default cluster token"
  cluster_id  = buildkite_cluster.primary.id
}

Then switching cluster_id = buildkite_cluster.primary.id to cluster_id = buildkite_cluster.secondary.id which then causes them to be recreated as the Cluster Queue and Agent Token cannot be moved between Clusters.