I have a redis-instance and a cloud-run in GCP.
At first, auth_enabled is set as false for redis-instance, and cloudrun can connect to redis. Also, i am able to connect to redis from local via a gcp-compute-engine(VM).
Now, i activated auth for redis, you can do it directly in GCP Console, or per terraform, by adding "auth_enabled = true" to resource "google_redis_instance".
After that, I can see in GCP-Console in Redis, a "auth_string" generated.
And with the generated auth_string, i can still connect to redis-instance from local via VM (Command used: redis-cli -h 127.0.0.1 -p 6379 -a <MY_REDIS_AUTH_STRING>).
But now the problem is, my cloudrun Application start is failed because cloud run cannot connect to redis anymore, and i don't know where to set the auth_string.
Error of Cloudrun-Application is:
"Constructor threw exception; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to xx.xx.xxx.xxx/<unresolved>:6379"
My Application is running on cloud run, and is a spring boot application with java version 17, Spring boot version 2.7.7, lettuce version 6.2.3.RELEASE
I think the generated "auth_string" is NOT equivalent with "password" of redis. Because i have tried to set the value of this Spring-Property "spring.data.redis.password" as the value of <auth_string> which can be copied from gcp-console, but still got the same error in logs.
Does anyone know, how can i set the auth_string in my spring boot application in order to connect to redis? Thank you very much!
We have found the solution. Our Setting is like this: (1) we have a gcp-redis-instanz, and the option "auth_enabled" is set as true, and after that gcp has generated automatically a redis-password for us (it is 36 character long and it is a UUID). (2) we have spring boot application, running on gcp cloud run. After redis auth is enabled, we used this redis_uri which contains the genenated passwort, then it works:
redis://<REDIS_PASSWORD>@<REDIS_HOST>:<REDIS_PORT>
Our mistake was, we saved the redis password in gcp secret manager and pass the secret for redis-password as envrionment vairbale to cloud run, but forgot to add the dependency of gcp-secret-manager in pom.xml, so secret can not be read correctly, that is why we got the error: "Unable to connect to xx.xx.xxx.xxx/:6379"
And the generated 36-character-long redis-AUTH-String is a redis-password, they both are the same thing.