serverless / serverless-google-cloudfunctions

Serverless Google Cloud Functions Plugin – Adds Google Cloud Functions support to the Serverless Framework
https://www.serverless.com
MIT License
271 stars 127 forks source link

runtime not added to template #170

Open dcarrion87 opened 5 years ago

dcarrion87 commented 5 years ago

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.

fakhrullah commented 5 years ago

Hi @dcarrion87

I have same problem.

How do you solved it?

fakhrullah commented 5 years ago

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.

cj2 commented 4 years ago

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

totegsito commented 4 years ago

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.

joshuaquek commented 4 years ago

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 commented 4 years ago

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

gustawdaniel commented 4 years ago

I think that example on page

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

should be updated by

damiana commented 4 years ago

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?

jimsorock commented 4 years ago

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

kevboutin commented 4 years ago

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.

victor23d commented 4 years ago

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.
NoTiger commented 3 years ago

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