serverless-google-cloudfunctions
serverless-google-cloudfunctions copied to clipboard
runtime not added to template
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.
Hi @dcarrion87
I have same problem.
How do you solved it?
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.
Same issue, this resolved it. Thanks @fakhrullah for the helpful post!
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.
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.
If it works for you guys we can close this issue.
I think that example on page
https://serverless.com/examples/google-node-simple-http-endpoint/
should be updated by
- adding runtime
- updating package version
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
serverless.yml
How do I solve it?
updating to the latest serverless-google-cloudfunctions
npm package version got me past this error, but ran into a different error.
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
serverless.yml
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.
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:
- Run
serverless create --template google-nodejs --path my-project
- In my-project, change the
project
andcredentials
field - Run
npm install
- Run
serverless deploy
I tested and it works.
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:
- Run
serverless create --template google-nodejs --path my-project
- In my-project, change the
project
andcredentials
field- Run
npm install
- 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