Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ref API gateway endpoint in serverless?

I am using serverless.yml as the infra. framework. I create a lambda with a API gateway like below code:

functions:
  create:
    handler: posts.create
    events:
      - http:
          path: posts/create
          method: post
          authorizer: xxx:xxx:Lambda-Name

it will generate a endpoint for the API gateway. But how can I reference this endpoint in other place in the yml file?

like image 887
Joey Yi Zhao Avatar asked Oct 15 '25 16:10

Joey Yi Zhao


1 Answers

Ref: ApiGatewayRestApi - ApiGatewayRestApi is a default Rest API logical ID.

How do I get/reference API gateway restAPI id in serverless.yml?

custom:
    webServiceEndpoint:
        Fn::Join:
          - ''
          - - 'https://'
            - Ref: ApiGatewayRestApi
            - '.execute-api.'
            - Ref: AWS::Region
            - '.amazonaws.com/'
            - ${self:provider.stage}
like image 79
elbik Avatar answered Oct 18 '25 17:10

elbik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!