3

not sure why but succesfull deployments for serverless GCP stopped working with the error:

team27> serverless deploy -c serverless_stage.yml Serverless: Packaging service... Serverless: Excluding development dependencies... Serverless: Compiling function "user"... Serverless: Compiling function "volunteer"... Serverless: Compiling function "clear"... Serverless: Uploading artifacts... Serverless: Artifacts successfully uploaded... Serverless: Updating deployment... Serverless: Checking deployment update progress... .. Error -------------------------------------------------- Error: Deployment failed: RESOURCE_ERROR {"ResourceType":"cloudfunctions.v1beta2.function","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"message":"The GCF v1beta2 API is deprecated. See https://cloud.google.com/functions/docs/migrating","status":"PERMISSION_DENIED","details":[],"statusMessage":"Forbidden","requestPath":"https://cloudfunctions.googleapis.com/v1beta2/projects/stageteam27/locations/us-central1/functions","httpMethod":"POST"}} at throwErrorIfDeploymentFails (xxx\team27\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:71:11) at xxx\team27\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:42:17 at processTicksAndRejections (internal/process/task_queues.js:93:5) For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable. Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com Your Environment Information --------------------------- Operating System: win32 Node Version: 12.13.1 Framework Version: 1.64.0 Plugin Version: 3.4.0 SDK Version: 2.3.0 Components Core Version: 1.1.2 Components CLI Version: 1.4.0 

As suggested in https://cloud.google.com/functions/docs/migrating I performed gcloud components update Same error...

Here is my yml:

service: stageteam27 provider: name: google stage: stage runtime: nodejs10 region: us-central1 project: stageteam27 credentials: /xxx/stageteam27keyfile.json environment: IS_PROD: 'false' plugins: - serverless-google-cloudfunctions package: exclude: - node_modules/** - .gitignore - .git/** functions: user: handler: userMessage events: - http: user volunteer: handler: volunteerMessage events: - http: volunteer clear: handler: clearCommand events: - http: clear 
1
  • If you land here with the original error (e.g. via Deployment Manager) the respective type change that has happened is cloudfunctions.v1beta2.functiongcp-types/cloudfunctions-v1:projects.locations.functions ; based on the migration reference by serverless-google-cloudfunctions Commented Jul 1, 2020 at 7:59

4 Answers 4

6

If you are using serverless framework to deploy your cloud functions in GCP, this following reference might help you,

https://github.com/serverless/serverless-google-cloudfunctions/blob/HEAD/MIGRATION_GUIDE.md


Option 2

The second is from the developers' point of view, which means that you need to make some changes to the serverless.yml.

1. Change the service name or change the function name to make sure this function is different from the older one. 2. Redeploy the functions. 3. Once it's done,you may consider delete the old ones. 

In addition to upgrading the serverless library and serverless-google-cloudfunctions plugin to the latest version, you can try to rename the service to other name than stageteam27 (e.g. stageteam27-v2, stageteam27-new, or stage-team-27).

In my case, only renaming the function cannot solve the deployment issue while the service name is still the old one.

Just one remark that the function name will now have the following pattern ${serviceName}-${stage}-${functionName}.

EDIT:

We can specify function name in the serverless.yml if we do not want to have such long function name.

For instance

service: myService provider: name: google stage: prod runtime: nodejs10 functions: myFunction: # this will be the function name name: myFunction handler: myFunctionHandler 

In that case, the deployed function name will be myFunction only. If we do not specify the name, it will be myService-prod-myFunction.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, only one clarification: I HAD to migrate from serverless-google-cloudfunctions=2.4.0 to serverless-google-cloudfunctions=3.1.0
Regarding your remark, any way to avoid this \ change it?
@MTZ4 That's right, 3.1.0 is mandatory, even the version 3.0.0 seems to be still buggy. I'm not 100% sure but this generated name seems to be a new non-backward-compatible expected behavior by checking the following pull requests: 216, 207, 206, and 165. It is better to double check on their official Github.
2

Google actually deprecated their previous version of the Cloud Functions API. There were changes made not so long to the Google Cloud Functions provider that you may nbot yet have so try upgrading the framework using npm i -g serverless and it should fix the issue. Failing that, try to see which version of the serverless-google-cloudfunctions module you use and upgrade that.

Comments

1

When installing via serverless.com templates, package.json referenced "serverless-google-cloudfunctions": "^2.3.3". Version 2.x is the problem. Reinstall the package with version 3.x.

I deleted that line in package.json and ran npm install serverless-google-cloudfunctions.

This installed versoin ^3.1.1 and my serverless deploy worked.

Comments

0

"dependencies": { "serverless-google-cloudfunctions": "^2.3.3" } package.json change version '^3.0.0'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.