serverless-google-cloudfunctions: Http trigger path ignored by deployment

I have a following function config in serverless.yml

functions:
  create-account:
    handler: createAccount
    events:
      - http: create-account

Yet when the deployment runs, I get:

Deployed functions
create-account
  https://us-central1-gcfteststuff.cloudfunctions.net/createAccount

In Deployment Manager dashboard the httpsTrigger value is set to url: create-account. What might be the issue?

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 3
  • Comments: 15 (3 by maintainers)

Most upvoted comments

As it is currently, I can only create Google Functions with names matching their handlers.

Example:

exports.http = (request, response) => {
  response.status(200).send('Hello World!')
}
service: my-service
...
functions:
  my-service:
    handler: http
    events:
      - http: my-service

The above will create a function named “http” and its URL:

https://us-central1-PROJECT_ID.cloudfunctions.net/http

While I would expect a function called “my-service” to be created with the URL:

https://us-central1-PROJECT_ID.cloudfunctions.net/my-service

I think the plugin needs to address this in another way, as in not relying on httpsTrigger, because it clearly has no effect in the function URL. The function name itself does.

I’ve been manually creating Google Functions and trying to switch to Serverless for deploys, but this issue is preventing me to.

Same issue here. Only http seem to work for name, meaning I can’t have more than one cloud function. That makes serverless useless. Does anyone know a workaround?

Seeing how this has been open for nearly two years and no progress, I guess we can’t expect a solution anytime soon.

Managed to find a solution to this, that allows for custom naming:

This Serverless.yml worked for me 👍🏼:

image

Things to take note of:

Naming convention has to be all lowercase WITHOUT SYMBOLS OR UPPERCASE. Else you will get the error of Error -------------------------------------------------- Error: Invalid value for field 'resource.name': 'sls-microserviceApp-dev'. Must be a match of regex '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?' at Gaxios._request (/home/vsts/work/1/s/node_modules/gaxios/src/gaxios.ts:109:15) at processTicksAndRejections (internal/process/task_queues.js:86:5)

✅Result:

Deployment Manager web console shows this:

image

Storage web console shows this:

image

Cloudfunction web console shows this:

image

Lastly:

I’m using ExpressJS for my routing within the cloudfunction. If you guys are wondering how, there are a few articles online that can be searched up: https://codeburst.io/express-js-on-cloud-functions-for-firebase-86ed26f9144c