How do I find the API endpoint of a lambda function?

梦想与她 提交于 2019-12-04 16:08:57

问题


I have a Lambda function that has an exposed API Gateway endpoint, and I can get the URL for that via the AWS console. However, I would like to get that URL via API call. Neither the Lambda API documentation nor the API Gateway documentation seem to have that information (or perhaps I've missed it), so is this even possible in the first place?


回答1:


Your API Gateway endpoint URL doesn't get exposed via an API call. However, since the URL of the API follows a certain structure, you could get all the necessary pieces and create the URI within your code.

https://API-ID.execute-api.REGION.amazonaws.com/STAGE

You could use apigateway:rest-apis to get your API-ID and restapi:stages to get the stage corresponding identifier.




回答2:


I don't really understand the above answer (maybe it's outdated?).

The absolute easiest way:

  1. Choose "API Gateway" under "Services" in AWS.
  2. Click on your API.
  3. Click on "Stages".
  4. Choose the stage you want to use
  5. Now you can see the entire URL very visible inside a blue box on the top with the heading "Invoke URL"



回答3:


Following up on @larschanders comment, if you create the gateway using CloudFormation, the endpoint URL is surfaced as one of the stack outputs.




回答4:


To get the API endpoint ,

first step is to deploy the API on a stage(dev/test/prod) then you will get the invoke url



来源:https://stackoverflow.com/questions/36560504/how-do-i-find-the-api-endpoint-of-a-lambda-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!