Few Tips & Tricks of Using 2nd Gen of Cloud Function

2022/03/162 min read
bookmark this
Responsive image

How to handler the Cloud Function Traffic Splitting?

From the 2nd gen of the cloud function, you can split the traffic between each revisions, or roll back the function to the previous version. Google has announced this feature around August 9, 2022, although I think AWS lambda already has this feature few year back then but still this's good feature to use for the serverless cloud function.

The reason cloud function can provide the traffic splitting is that 2nd gen's cloud function is using Cloud Run. sample cloud function with Cloud Run

Modify the Manage Traffic

Once you click the link to go the Cloud Run from cloud function page, then click the REVISIONS so you can see all the version of the cloud function has deployed, so at this screen you can either split the traffic to 50% to the latest version, the rest 50% to the previous version, or you can change entire traffic to the previous if there'a any issue at the latest version. sample cloud function with Cloud Run

What policy permission require for run gcloud functions deploy

To run gcloud functions deploy, seems like require Cloud Functions Admin role at least to run, not find document where specify the permission for gcloud functions deploy, but have use the new user from the admin,tried following scenarios.

  • use the new email with Editor role
  • use the new email with Cloud Functions Developer role So, these 2 role didn't work out, throw error when run the command gcloud functions deploye...