apiKeys in Google Cloud

Greetings,

I am using Serverless to deploy a function in Google cloud. On AWS cloud I can use ‘apiKeys’ to generate a new API Key and protect my Lambda function with that API key when I declare the Lambda function as ‘private’ in the serverless.yml. Is there a similar way to generate an API key in Google Cloud? Similar setup in my Google Cloud serverless.yml is not deploying.

I am getting the following error:
Error: Unexpected token : in JSON at position 19
at provider.request.then.catch (/Users/skarlekar/test/gcp-api-key/node_modules/serverless-google-cloudfunctions/shared/monitorDeployment.js:51:24)
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:360:22)
at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:391:17)
at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:99:33)
at runCallback (timers.js:781:20)
at tryOnImmediate (timers.js:743:5)
at processImmediate [as _immediateCallback] (timers.js:714:5)
From previous event:
at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:86:74)
at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:39:50)
at

My serverless.yml is:
service: gcp-api-key

provider:
name: google
runtime: nodejs
project: myproject-01
credentials: ~/GCP/Credentials/myproject-01-2fdfdaff.json
apiKeys:
- myApiKey

plugins:

  • serverless-google-cloudfunctions
    package:
    exclude:
    • node_modules/**
    • .gitignore
    • .git/**

functions:
apiKeyTest:
handler: testKey
events:
- http:
path: mypath
method: get
private: true

Any updates on this? In my opinion, this is a must-have.

I don’t believe path and method are valid definitions in your serverless.yml for GCP. Please read: https://www.serverless.com/framework/docs/providers/google/events/http/