RedisLabs / terraform-provider-rediscloud

Terraform Redis Cloud Provider: Deploy, update, and manage Redis Cloud databases as code through HashiCorp Terraform
https://registry.terraform.io/providers/RedisLabs/rediscloud/latest
Apache License 2.0
30 stars 23 forks source link

Provider is panicking when listing databases #457

Closed ksh-chy closed 9 months ago

ksh-chy commented 9 months ago

Hi,

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v1.6.3-dev
on linux_amd64
...
+ provider registry.terraform.io/redislabs/rediscloud v1.5.0
...

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "rediscloud_subscription_database" "database" {
  for_each = local.shards

  subscription_id = rediscloud_subscription.$NAME.id
  name = "$NAME-${each.key}"
  memory_limit_in_gb = 10
  data_persistence = "aof-every-1-second"
  throughput_measurement_by = "operations-per-second"
  throughput_measurement_value = 1000
  protocol = "redis"
  password = $PW

  periodic_backup_path = "$PATH"

  alert {
    name = "dataset-size"
    value = 90
  }
  depends_on = [rediscloud_subscription.$NAME]

  lifecycle {
    prevent_destroy = true
  }
}

Debug Output

https://gist.github.com/ksh-chy/eff401edc109c89d49a76e50d5009960

Panic Output

https://gist.github.com/ksh-chy/bd38aff1e0fae1b19ceba51cff9e926d

Expected Behavior

Should tf plan successfully

Actual Behavior

Panic :(

Steps to Reproduce

  1. Setup a "rediscloud_database" datasource.
  2. terraform plan

Important Factoids

Nothing too weird, running on GCP.

References

ksh-chy commented 9 months ago

I believe the issue is in the pagination logic in rediscloud-go-api. When we try to access the second page (offset=100, pagesize=100) the API returns 200, with no databases.

tomerzvirsh commented 9 months ago

Hi @ksh-chy, This issue should be resolved now.

ksh-chy commented 9 months ago

Thanks @tomerzvirsh - looks good on my end now :)