Google Cloud Functions Error: Forbidden


Google Cloud Functions seem to have changed recently and the change seems to be for security reasons, previously when I created new cloud functions they would deploy and just work, however now Google cloud functions require you to set permissions on who can invoke them, presumably so you don't accidentally deploy a private function publicly.


If you create a new Google Cloud Function and receive the following error, it may be due to the permissions set on the function.


Error: Forbidden
Your client does not have permission to get URL /Function from this server.


Set permissions on Google Cloud Function

Note: The following guide is based on the use case of a publicly accessible API endpoint, if you don't want the function to be publicly accessible adjust the permissions accordingly.

  1. Navigate to the functions list cloud.google.com/functions/list
  2. In the top left of the screen click on "Show Info Panel" if the panel is already displayed you will see "Hide info panel"

  3. Select a function in the function list to load the properties in the info panel.

  4. Click the "Add member" button, this will display an "Add users" screen

  5. In the new members field, type in "allUsers" and select the "allUsers" option. allUsers enables anyone with the link to invoke your function.

  6. In the "Select a role" dropdown, select Cloud Functions then Cloud Functions Invoker. This role enables all users to invoke a Google cloud function, they can only invoke the function and have restricted access.

  7. Click Save, a popup will appear for you to confirm you'd like to enable public access, click Allow public access, you should now be able to invoke your function.

Was this helpful?

Yes No


Comments

Post a Comment