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

Way to configure proper http path to Google Cloud Functions #148

Open AndreyPoznyak opened 5 years ago

AndreyPoznyak commented 5 years ago

This is a Bug Report

Description

I have the following config in my .yml: getArticles: handler: getAllArticles events: - http: articles/all

However after the successful deployment Serverless creates the following endpoint for me: "https://***.cloudfunctions.net/getAllArticles" when I want it to be "https://***.cloudfunctions.net/articles/all"

Why do the values from config get ignored and it makes the http path equal to handler name?

Additional Data

Serverless.js 1.26.0 Max OS X 10.13.2

drgomesp commented 3 years ago

Any updates on supporting this?

Gnucki commented 3 years ago

Seems to me it is a non overridable behaviour of gcloud. Do you succeed in doing this without serverless ?

drgomesp commented 3 years ago

I believe a good way to solve this issue is to make all API management through Cloud Endpoints. Find more info on how to do a basic setup here: https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions

In short, you'd be able to do something like:

paths:
  /foo/bar/hello:
    get:
      summary: Greet a user
      operationId: hello
      x-google-backend:
        address: https://REGION-FUNCTIONS_PROJECT_ID.cloudfunctions.net/helloFunctionName
        protocol: h2
      responses:
        '200':
          description: A successful response
          schema:
            type: string

With this, I was able to map the generated path names to whatever paths I wanted to on Cloud Endpoints.