terraform-provider-grafana
terraform-provider-grafana copied to clipboard
Adding an user to an organization when there is more than 1000 accounts does not work
Terraform Version
Terraform v0.14.6
- provider registry.terraform.io/grafana/grafana v1.9.0
Expected Behavior
When creating a new organization with users and with create_users parameter to false, the provider should be able to parse the whole users list to verify if the user already exists. Then if it exists, it should just add the user to the organisation.
Actual Behavior
Due to more than 1000 users in the user database, and due to HTTP api limitation that returns only the first 1000 users, if the user already exists but at the end of that list, the provider gives an error that the user does not exists
Steps to Reproduce
- have more than 1000 users accounts
- create an organization with a user that have an id bigger than the 1000th user
- terraform apply
Important Factoids
My grafana instance contains more than 1000 users, from multiple sources (local and external)
References
the Users function: https://github.com/grafana/terraform-provider-grafana/blob/87812f448ed79f3678deb9f53454ce2a74ddd184/vendor/github.com/grafana/grafana-api-golang-client/user.go#L48
the retrieval of the first page: https://github.com/grafana/terraform-provider-grafana/blob/87812f448ed79f3678deb9f53454ce2a74ddd184/grafana/resource_organization.go#L257
the official documentation that explains the first 1000 results limitation: https://grafana.com/docs/grafana/latest/http_api/user/#search-users