buildkite / terraform-provider-buildkite

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

Feature request: Add `key` or `name` field for the buildkite_cluster_default_queue resource #520

Closed jasmineqin1010 closed 5 months ago

jasmineqin1010 commented 5 months ago

Currently, a buildkite_cluster_default_queue doesn’t support the field key (or similar that indicates the name of the queue) like a regular queue would.

The issue with this is that if we want to change the name of the default queue, we can’t really perform that change within the .tf file that contains the Terraform resources, and it can be quite inconvenient especially if we want to enforce every change (creation/modification/deletion) to go through Terraform IaC and not via UI.

Therefore, the feature we are requesting is essentially the addition of a field to indicate the name of the default queue, so something like

resource "buildkite_cluster_default_queue" "test_x86" {
  cluster_id = "Q2x1c3Rlci0tLWU3MDcxxxx"
  queue_id   = "Q2x1c3RlclF1ZXVlLS0yyyy"
  key        = "test-x86"
}

Thank you!

mcncl commented 5 months ago

Hey @jasmineqin1010! Thanks for raising this. I've relabelled this as an enhancement rather than a bug. It looks like we should be able to support the addition of the field, assuming it's only for use in the state? If it's for an API call then it will be a little more complex and will require some additional planning, however if it's more for reference then I can see this being feasible by the end of the week.

mcncl commented 5 months ago

@jasmineqin1010 looking in to this a little more, the purpose of the buildkite_cluster_default_queue resource is to provide a link to an existing queue and cluster to assign the former as the latter's default. We couldn't want this resource to ever be able to change the key of the queue that is assigned as the default.

mcncl commented 5 months ago

@jasmineqin1010 I've opened a PR to expose the key as a read only attribute. This would make it visible/accessible in state.

jasmineqin1010 commented 5 months ago

@jasmineqin1010 looking in to this a little more, the purpose of the buildkite_cluster_default_queue resource is to provide a link to an existing queue and cluster to assign the former as the latter's default. We couldn't want this resource to ever be able to change the key of the queue that is assigned as the default.

Hi @mcncl , thank you for the contexts. Could you advise further that if we would like to modify the default queue's key, what's the right steps to follow? I assume something like:

Please let me know if any assumption above is incorrect.

mcncl commented 5 months ago

Hey @jasmineqin1010!

If you want to modify the key of the default queue then you should just be able to modify the key of the queue you wish to use as the default.

# create a cluster
resource "buildkite_cluster" "primary" {
  name        = "Primary cluster"
  description = "Runs the monolith build and deploy"
  emoji       = "🚀"
  color       = "#bada55"
}

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
  ### KEY = "default"
}

Change the config to:

# create a cluster
resource "buildkite_cluster" "primary" {
  name        = "Primary cluster"
  description = "Runs the monolith build and deploy"
  emoji       = "🚀"
  color       = "#bada55"
}

resource "buildkite_cluster_queue" "default" {
  cluster_id = buildkite_cluster.primary.id
  key        = "macos" <<-------- CHANGED
}

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