I have a Flask app in Google App Engine Standard Environment Python, and I also have a Cloud Function with an HTTP trigger which accepts a JSON body including the URL of a file. The CF downloads the file at that URL then saves it to a GCS bucket. The GAE service account has Cloud Function Invoker permissions, yet when using urlfetch.fetch()
in my GAE code to trigger CF, the App Engine code gets a 403 Forbidden
error unless I make the CF trigger callable by anyone.
How do I successfully call/trigger CF's from GAE in Python? I assume the answer is one of these:
- Set IAM permissions on GAE service account to {enlighten me here}
- Add authentication headers in
urlfetch.fetch()
like so {different enlightenment} - Make CF triggerable from anywhere, but hard code some secret key so the CF code itself handles authentication.
Authorization: Bearer [IDENTITY_TOKEN]
header when calling Cloud Functions protected by IAP authorization. – John Hanley