0

PyCharm's Cloud Code plugin will let me run and deploy Google Cloud Run services. However, when I try to set up a local configuration, I am not sure how to specify my Google Application Credentials.

I know how to mount this via the command line using docker run, but I don't know how to specify the service account. There is a "service account" field, in which I have input both the path to the key file, as well as the email address of the service account (neither work)

enter image description here

Abby Carey
  • 40
  • 7
dcells
  • 3
  • 3
  • Do you have a service account key file? – guillaume blaquiere Aug 30 '20 at 11:43
  • Could you please check if this other similar case [here](https://stackoverflow.com/questions/58319513/how-to-add-service-account-credentials-to-google-app-engine-when-debugging-with) helps you? It provides a varied of ways to set up your Service Account for usage with Cloud Intellij. – gso_gabriel Aug 31 '20 at 08:04
  • @guillaumeblaquiere I do – dcells Sep 18 '20 at 11:54

1 Answers1

0

I'm a Developer Advocate with the Cloud Code team. Without knowing the error you're getting, it's hard to tell if this is an IAM or auth config issue.

In the config, adding the email address of your service account to the "Service Account" field should do the trick here.

I just tested this by doing the following:

  1. Create a new Python Flask Cloud Run project using a starter template Cloud Code provides.
  2. Edit the Cloud Run: Run Locally config's "Service Account" field to include the email address of my service account. Note that I gave this service account Owner permission for testing.
  3. Add in a Cloud Translate snippet https://cloud.google.com/translate/docs/advanced/translating-text-v3#translating_input_strings
  4. Run the Cloud Run: Run locally configuration

Once the service was running, I opened the URL in the Event Log and the translate API was called successfully.

Alternatively, you could add your service account's key.json file to your project, create a new environment variable in your Dockerfile named GOOGLE_APPLICATION_CREDENTIALS, and set that variable equal to the path of your key.json file.

Reference:

https://cloud.google.com/code/docs/intellij/developing-a-cloud-run-app https://cloud.google.com/run/docs/configuring/service-accounts

Abby Carey
  • 40
  • 7
  • The steps you outlined work great! Not sure what my issue was, maybe related to using an already-existing project. – dcells Sep 18 '20 at 14:48