1

I have a simple spring boot microservice (gradle) that I want to deploy on cloud run and use cloud Firestore for storing some data. I configured it locally, so I can read and write data to firestore. If I create and run a docker image of the application locally, it works. When I deploy it on cloud run, the application starts normally,

Logs in cloud run

except when it tries to read data from firestore (when I call an endpoint), I get the following exception in postman:

java.util.concurrent.ExecutionException: com.google.api.gax.rpc.PermissionDeniedException: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Missing or insufficient permissions.

On cloud, docker image is created with cloud build, through my github repo.

What should I do to make it work on cloud run?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Question. Is your local service account permissions are the same with those on the deployed env.? – Antal Attila Oct 15 '21 at 08:22
  • Yes, I used the same service account – paulcobzaru Oct 15 '21 at 08:24
  • Is this related? https://stackoverflow.com/questions/52772199/credentials-failed-to-obtain-metadata-error-when-trying-to-auth-java-client-to – Antal Attila Oct 15 '21 at 08:29
  • Not really, I successfully connected to firestore from my local machine and from a docker container locally. The problem is only when the application runs on Cloud Run. There are some weird logs when I make a call to the service. – paulcobzaru Oct 15 '21 at 08:42
  • How do you deploy? How do you test locally with the same service account (how do you load it)? Can you share these pieces of code? – guillaume blaquiere Oct 15 '21 at 18:35

1 Answers1

1

I found the problem.

I followed instructions from this documentation and here it is used this library:

compile 'com.google.cloud:google-cloud-firestore:1.32.0'

Then I tried with this library (this is documentation) and everything worked!

implementation 'com.google.firebase:firebase-admin:8.1.0'