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.
- Navigate to the functions list cloud.google.com/functions/list
- In the top left of the screen click on "Show Info Panel" if the panel is already displayed you will see "Hide info panel"
- Select a function in the function list to load the properties in the info panel.
- Click the "Add member" button, this will display an "Add users" screen
- 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.
Was this helpful?
Superb tutorial chief
ReplyDelete