Search code examples
pythongoogle-cloud-platformgoogle-cloud-functionsserverless-frameworkserverless

Serverless GCP Function deployment


I am trying to deploy the GCP Cloud Function using serverless node module. while I have followed the instructions from site but still I am facing following error.

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
Serverless: Compiling function "ProductVersion"...
Serverless: Uploading artifacts...
Serverless: Artifacts successfully uploaded...
Serverless: Updating deployment...
Serverless: Checking deployment update progress...
. 
 Error ---------------------------------------------------
 
  Error: Deployment failed: RESOURCE_ERROR
  
       {"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"message":"Permission 'cloudfunctions.functions.create' denied on resource 'projects/123456/locations/us-central1/functions/demeter-dev-ProductVersion' (or resource may not exist).","status":"PERMISSION_DENIED","statusMessage":"Forbidden","requestPath":"https://cloudfunctions.googleapis.com/v1/projects/123456/locations/us-central1/functions","httpMethod":"POST"}}
      at throwErrorIfDeploymentFails (/home/demo/workspace/demo/demeter/node_modules/serverless-google-cloudfunctions/shared/monitorDeployment.js:71:11)
      at provider.request.then (/home/demo/workspace/demo/demeter/node_modules/serverless-google-cloudfunctions/shared/monitorDeployment.js:42:17)
      at process._tickCallback (internal/process/next_tick.js:68:7)

I have configured my GCP Service account with following permission which required but it is still not working.

1.Cloud Functions Admin

2.Cloud Functions developer

3.Deployment manager editor

4.logging admin

5.storage admin

Here is my serverless.yml file

service: demo

package:
  exclude:
    - node_modules/**
    - .gitignore
    - .git/**
    - .idea/**

plugins:
  - serverless-google-cloudfunctions
  - serverless-python-requirements
  - serverless-prune-plugin

provider:
  name: google
  runtime: python37
  project: 123456
  credentials: ./cred.json # path must be absolute

functions:
  ProductVersion:
    handler: get_pronto_app_version
    events:
      - http: path

Can anyone please help me out


Solution

  • It got resolved by changing the project variable in serverless.yml file I was mentioning the numeric id but it was expecting the alphanumeric id of the project that we see on the dashboard of GCP. Somehow it was not throwing the exact error but after wasting lots of time in it got resolved.

    project: myproject12
    

    Thanks everyone for answering this question.