Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I'm using Serverless Framework to deploy functions in AWS Lambda, but I can't find where/how I can remove the stage specifier from the URL endpoints created. The documentation does not seem to cover this part.

For example, this is my serverless.yml (with irrelevant parts omitted):

service: cd-mock

provider:

  name: aws

  runtime: python3.6

  region: eu-west-1

package:

  include:

    - handler.py

functions:

  index:

    handler: handler.index

    events:

      - http:

          path: /

          method: get

After a serverless deploy, the following service information is returned:

service: cd-mock

stage: dev

region: eu-west-1

stack: cd-mock-dev

api keys:

  None

endpoints:

  GET - https://ab1cd2ef3g.execute-api.eu-west-1.amazonaws.com/dev/

functions:

  index: cd-mock-dev-index

Notice the /dev part in the URL endpoint, and also in the function. That dev is the default value for the stage parameter in the configuration file.

Specifying stage: something in the serverless.yml file will have that /something as a suffix in the URL and as part of the function.

Question: How can I remove the stage specification from the generated URL endpoints, or: how can I prevent that stage specification to become part of the generated URLs?

(That the stage is part of the function, is fine. That will be easy to separate staging and production functions in the AWS Lambda dashboard.)

closed

1 Answer

0 votes
by (44.4k points)
selected by
 
Best answer
  • This is an API Gateway feature/convention NOT from Serverless Framework so serverless can't do anything about it.
  • At the end of your endpoint, it is appended and the API Gateway requires you with a stage.
  • API Gateway endpoints are meant for developers though so it is not meant to be user-friendly.
  • If you want it to be user-friendly, you can add a custom domain for it. Different stages can have different custom subdomains.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...