Get Gateway API end point in lambda function

Any idea how to get he Gateway API end point in my lambda function, so I can do the service registration to a Service Registrar?

Hey @carmely

Are you talking about adding a custom domain on top of your API gateway endpoint? http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html#how-to-custom-domains-console

Wiring up API gateway to a lambda function can be done like so: https://serverless.com/framework/docs/providers/aws/events/apigateway#http-endpoint-with-extended-options

I’ll throw in a third option… are you trying to work out your endpoint URL from inside your Lambda function that handles the endpoint?

const url = event.headers["X-Forwarded-Proto"] + "://" + event.headers["Host"] + "/" + event.requestContext["stage"] + event.path
1 Like

Thanks. Yes, that is what I want. Actually I am thinking about the service discovery. When I use serverless to deploy the lambda functions, Gateway APIs will be auto-created. I need the HTTP end points for these Gateway APIs, so I can create records in Service Registrar(probably Dynamo DB). Previously I was thinking if there were any events thrown out on Gateway API creation, then I can have another lambda function listen to it and do the registration. However, AWS does not provide such events. Any idea for the alternatives? or do I have to make the Gateway API immutable by adding a custom domain manually?

1 Like