serverless-google-cloudfunctions icon indicating copy to clipboard operation
serverless-google-cloudfunctions copied to clipboard

runtime not added to template

Open dcarrion87 opened this issue 5 years ago • 12 comments

On sls deploy:

{"ResourceType":"cloudfunctions.v1beta2.function","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"The request has errors","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"runtime","description":"Runtime field cannot be empty."}]}],"statusMessage":"Bad Request","requestPath":"https://cloudfunctions.googleapis.com/v1beta2/projects/sunny-buttress-xxxxx/locations/us-central1/functions","httpMethod":"POST"}}

Had to adjust serverless-google-cloudfunctions/package/lib/compileFunctions.js to push runtime through.

dcarrion87 avatar Jun 05 '19 11:06 dcarrion87

Hi @dcarrion87

I have same problem.

How do you solved it?

fakhrullah avatar Aug 25 '19 13:08 fakhrullah

Ok. Found it.

I had to add in serverless-google-cloudfunctions/package/lib/compileFunctions.js:

const getFunctionTemplate = (funcObject, region, sourceArchiveUrl) => { //eslint-disable-line
  return {
    // ....
    properties: {
      runtime: 'nodejs8',
      //...
    },
  };
};

Currently Google Cloud Functions only allow 2 type nodejs runtime environment:

nodejs8 & nodejs10 (beta)

Refer here: https://cloud.google.com/functions/docs/concepts/exec

So, how we solve this in this code instead adjust ourself.

I am new in this serverless framework. Really hope someone can PR the fix.

Thank you.

fakhrullah avatar Aug 25 '19 14:08 fakhrullah

Same issue, this resolved it. Thanks @fakhrullah for the helpful post!

cj2 avatar Oct 11 '19 12:10 cj2

Hello, it also works if you add the runtime to your functions

functions:
  deploy:
    runtime: 'nodejs8'
    handler: http
    events:
      - http: path

This way you don't need to update external dependencies.

totegsito avatar Dec 18 '19 19:12 totegsito

I had the issue too. If you're using the examples provided, then the serverless-google-cloudfunctions package version is outdated at version 1 point something inside the example's package.json file.

Just make sure that you have this:

"serverless-google-cloudfunctions": "^2.3.3",

in your package.json file and it should work.

joshuaquek avatar Dec 19 '19 09:12 joshuaquek

If it works for you guys we can close this issue.

joshuaquek avatar Dec 19 '19 09:12 joshuaquek

I think that example on page

https://serverless.com/examples/google-node-simple-http-endpoint/

should be updated by

  • adding runtime
  • updating package version

gustawdaniel avatar Mar 23 '20 10:03 gustawdaniel

I have the same problem. It already includes the runtime tag in the functions, I updated the serverless plugin version to "^ 2.4.2" but I can't execute it.

Error image

serverless.yml image

How do I solve it?

damiana avatar Mar 26 '20 19:03 damiana

updating to the latest serverless-google-cloudfunctions npm package version got me past this error, but ran into a different error.

jimsorock avatar Apr 08 '20 06:04 jimsorock

I have the same problem. It already includes the runtime tag in the functions, I updated the serverless plugin version to "^ 2.4.2" but I can't execute it.

Error image

serverless.yml image

How do I solve it?

Looking at your error it would appear that you specified a timeout of 30, which is not valid. Try using 30s instead.

kevboutin avatar Apr 21 '20 19:04 kevboutin

The same issue with you when I following this example: https://github.com/serverless/examples/tree/master/google-node-simple-http-endpoint I think this example is outdated.

This is the working document https://serverless.com/framework/docs/providers/google/guide/quick-start/ Solution: If you want to see the correct example:

  1. Run serverless create --template google-nodejs --path my-project
  2. In my-project, change the project and credentials field
  3. Run npm install
  4. Run serverless deploy I tested and it works.

victor23d avatar Apr 26 '20 12:04 victor23d

The same issue with you when I following this example: https://github.com/serverless/examples/tree/master/google-node-simple-http-endpoint I think this example is outdated.

This is the working document https://serverless.com/framework/docs/providers/google/guide/quick-start/ Solution: If you want to see the correct example:

  1. Run serverless create --template google-nodejs --path my-project
  2. In my-project, change the project and credentials field
  3. Run npm install
  4. Run serverless deploy I tested and it works.

Actually, it is not the template that do the trick, i compared the template serverless.yml and my original serverless.yml. These are the missing link (put what you miss under 'provider'):

provider: name: google stage: dev runtime: nodejs10 region: us-central1

NoTiger avatar Oct 23 '20 09:10 NoTiger