The following setup exist and works fine:
Google Cloud Run (my API worked when I used the open URL - i.e. something like this https://some_name-ab3adasmjk-oa.a.run.app)
Google Cloud Scheduler (calling the above API by a HTTP, something like this URL = https://some_name-ab3adasmjk-oa.a.run.app/v1/myapi?id=0)
Now the problem: I PRESSED THIS BUTTON "SECURITY" that was shown inside my Google Cloud Run console!
After adding the "SECRET MANAGER SECRET ACCESSOR" to the Service-Account of the Google Cloud Run service (as required after pressing this "Security" button), then the Scheduler no longer works!
I followed all steps that are described in this post - but the "permission denied" for the Scheduler still remains!
What I did:
A) Add "SECRET MANAGER SECRET ACCESSOR" to the Service Account of the Google Cloud Run (as expected after pressing this button).
B) Add "OIDC Token" inside the Google Cloud Scheduler
C) Also, the Google Cloud Run API is hosted on a different "region" than the Google Cloud Scheduler. Is that a problem? (It was no problem yesterday!)
Did I miss something?
Questions:
After the service-account has the "SECRET MANAGER SECRET ACCESSOR", do I still use the Google Cloud Run URL inside the Scheduler - or do I need a different URL now? (https://some_name-ab3adasmjk-oa.a.run.app ?)
Inside the Scheduler, I did add "Add OIDC Token" and giving the Service Account of my Cloud Run API. I left Audience blank. Is that correct? Or is something else missing?
Additional information:
Steps I did and questions:
0.) Is it a problem to be on two different regions for Cloud Run API and Cloud Scheduler?
I)
I created a first Service Account SA1
for the Google Cloud Run, giving it the SECRET MANAGER SECRET ACCESSOR
permission
II)
As mentioned in post, I created a second Service Account SA2
to IAM: i.e. service-YOUR_PROJECT_NUMBER@gcp-sa-cloudscheduler.iam.gserviceaccount.com
giving it the role Cloud Scheduler Service Agent
III) Is it correct that under Add OIDC token
, I need to add SA1
? (or is it SA2
?)
IV)
Not sure how this works: As desribed in the same post, there is the need to grant roles/cloudfunctions.invoker
(or if using a 2nd Generation Environment Server, then roles/run.invoker
instead)
--> how do I do that exactly? Step-by-step description PLEASE!
--> What is the exact naming of the Permission if I want to grant Access?
All I can find in the Web-Console is Clud Run Service Agent
- but where can I find the option roles/run.invoker
?
--> To what Service Account do I have to give this roles/run.invoker
permission ? (i.e. is it to SA1 or SA2?)
https://some_name-ab3adasmjk-oa.a.run.app
and nothttps://some_name-ab3adasmjk-oa.a.run.app/v1/myapi?id=0
. – Eastboundgcloud auth print-identity-token
and the CLI toolcurl
. cloud.google.com/sdk/gcloud/reference/auth/print-identity-token and cloud.google.com/run/docs/authenticating/developers#curl – Eastboundroles/run.invoker
successfully via CLI (..did not know it existed ;)). I also placed the Scheduler on the sameregion
as the Cloud Run. BUT IT STILL DOES NOT WORK. This is turning me nuts! – Peloquincurl
as I showed previously. Once that works, debug Cloud Scheduler calling your Cloud Run endpoint. – Eastboundroles/run.invoker
is the glc-terminal command - and if you use the console, it is calledCloud Run Invoker
permission. The confusion not enough, I give a detailed explanation as an answer here below. Thank you @JohnHanley for your kind support! – Peloquin