buildkite / terraform-provider-buildkite

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

`inconsistent result after apply` when trying to move cluster_agent_token or cluster_queue between clusters #553

Closed bpoland closed 3 months ago

bpoland commented 4 months ago

Describe the bug When trying to change the cluster of a cluster_agent_token or cluster_queue resource, I get the following error consistently:

 Error: Provider produced inconsistent result after apply
│
│ When applying changes to buildkite_cluster_agent_token.this, provider "provider[\"registry.terraform.io/buildkite/buildkite\"]" produced an unexpected new value: .cluster_id: was
│ cty.StringVal("redacted1"), but now cty.StringVal("redacted2").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

I was able to work around by manually tainting the resource and having terraform delete and recreate in the new cluster.

To Reproduce Steps to reproduce the behavior:

  1. Terraform a cluster with a queue and/or agent token
  2. Terraform a second cluster, and update the cluster on the queue/agent token to the new one
  3. Planning shows that the resource will be moved:
# buildkite_cluster_queue.this will be updated in-place
  ~ resource "buildkite_cluster_queue" "this" {
      ~ cluster_id   = "redacted1" -> "redacted2"
        id           = "redacted3"
        # (3 unchanged attributes hidden)
    }
  1. But apply shows the error displayed above and the queue/agent token is not changed.

Expected behavior Given the UI does not provide a way to move either of these things between clusters, I suspect the provider should just understand that it needs to delete and recreate them on its own and show that in the plan.

tomowatt commented 4 months ago

Hey @bpoland

Thanks for raising this, well spotted as Agent Tokens and Queues cannot be moved between Clusters.

tomowatt commented 3 months ago

Hey @bpoland We've now released v1.10.2 which contains fixes to ensure the the Cluster Agent Tokens and Queues Resources are recreated if the Cluster ID changes rather than erroring out. Let us know if that fixes what you experienced!

bpoland commented 3 months ago

Hey @bpoland We've now released v1.10.2 which contains fixes to ensure the the Cluster Agent Tokens and Queues Resources are recreated if the Cluster ID changes rather than erroring out. Let us know if that fixes what you experienced!

Thanks that looks great! Just confirmed with a local plan that this is working for me:

~ cluster_id   = "old" -> "new" # forces replacement