'How to get aws api gateway endpoint url from command line interface
I have created an aws lambda function by following aws tutorial located here. https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html
Once the app is deployed using sam cli the output shows the api gateway endpoint url. I would like to know how I can retrieve this information for a function which is already deployed using the command line interface.
Thank you
Solution 1:[1]
No, that is not possible. A lambda does not have a URL.
An Api Gateway does have a public URL because that is the point of an Api Gateway, to make internal functions such as lambdas publicly accessible. If you want to make an existing lambda publicly accessible either incorporate it into an existing Api Gateway or set up a new gateway with the lambda as a target. To know how to integrate it into an Api Gateway is too much to cover in this answer, there a thousands of tutorials out there.
Solution 2:[2]
EDIT after clarifications in comments:
aws apigatewayv2 get-apis
Output example:
{
"Items": [
{
"ApiEndpoint": "wss://ko1uatx3.execute-api.eu-north-1.amazonaws.com",
"ApiId": "ko1uatx3",
"ApiKeySelectionExpression": "$request.header.x-api-key",
"CreatedDate": "2021-07-07T08:54:13Z",
"Description": "Serverless Websockets",
"Name": "dev-scrum-estimation-serverless-websockets",
"ProtocolType": "WEBSOCKET",
"RouteSelectionExpression": "$request.body.action",
"Tags": {}
}
]
}
Solution 3:[3]
Perhaps I am not understanding the question but for anyone coming here looking for a list of API Gateway paths, you can pull the endpoint names out of API Gateway using aws apigateway get-resources. Replace abcd1234 with your API Gateway instance ID.
aws apigateway get-resources --rest-api-id abcd1234
If you need just the URL names, you can use something like jq to extract just the path property:
aws apigateway get-resources --rest-api-id abcd1234 | jq '.items[ ] | .path'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | luk2302 |
| Solution 2 | |
| Solution 3 | hvaughan3 |
