upstash / terraform-provider-upstash

MIT License
22 stars 4 forks source link

Programmatically read Redis database token for REST #8

Closed fdionisi closed 2 years ago

fdionisi commented 2 years ago

While waiting for #6, I started looking at Updash's Redis REST alternative. In my understanding, this approach would be better for serverless applications (i.e. as written in https://github.com/upstash/upstash-redis).

I'm facing the issue now that I can't programmatically read the token necessary for authenticating the Upstash Redis client. The format is very different from a Management API token (which is a UUID), and I'm unable to find it anywhere in the web console, if not in the database details section. This behaviour raises a similar issue as described in #6, where I cannot successfully deploy a resource connecting to a newly created database in one go, as the token is unknown until after database creation.

Moreover, I didn't find a way to read it through Terraform, forcing me to add the token to my environment variable manually. I'm also wondering what would happen when I introduce multiple terraform workspaces: would I have to add each token to my environment variables? This process wouldn't be ideal as it is based on human interaction, therefore error-prone, and not immediately apparent to other developers (e.g. new joiners).

What would be your suggested way to handle this situation?

Edit: digging a bit deeper, I noticed that upon resource creation (update and deletion), the resource is always freshly fetched from the API ^1. From the get database documentation ^2, the rest_token is already part of the payload, so perhaps exposing it in Terraform is as simple as specifying it similarly as done in #7.

burak-upstash commented 2 years ago

Hey, thanks for the issue! We will be checking if any other info similar to those are missing with the provider.

buggyhunter commented 2 years ago

https://registry.terraform.io/providers/upstash/upstash/1.0.2 has been released with a fix closing issue for now