cockroachdb / terraform-provider-cockroach

Terraform provider for CockroachDB Cloud
Apache License 2.0
56 stars 10 forks source link

Provider fails to implement pagination for >100 SQL users, causing user creation conflicts #121

Closed samdotci closed 1 year ago

samdotci commented 1 year ago

Issue Description:

The Terraform provider incorrectly handles pagination when verifying SQL users in the state. When more than 100 SQL users are present, it only retrieves the first 100 due to the default page size. This causes warnings during each Terraform run for a SQL cluster with more than 100 users and errors when applying changes due to conflicts with existing, unfetched users.

The warning during the plan appears as below:

This cluster doesn't have a SQL user named... Removing from state..

Expected Behavior

The provider should correctly implement pagination to verify all SQL users when their count exceeds 100.

Steps to Reproduce:

  1. Write Terraform code that would provision >100 SQL users for a cluster
  2. Execute a terraform apply
  3. Observe the success of the apply (assuming there were no existing users in the state)
  4. Execute a terraform apply again
  5. Observe the warnings indicating that some SQL users are missing, and that they will need to be recreated
  6. Try to apply changes and observe the resultant errors due to user creation conflicts.

Proposed Solution

I have created a PR to resolve this issue.

erademacher commented 1 year ago

Fixed in v0.6.0.