Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 652
howcheng Avatar asked Apr 11 '16 22:04

howcheng


People also ask

Can I call API from Lambda function?

To test your API Copy your API's invoke URL, and enter it in a web browser. Append the name of your Lambda function to your invoke URL to call your Lambda function. By default, the API Gateway console creates a route with the same name as your Lambda function, my-function .

Does AWS Lambda have an endpoint?

You can create an interface endpoint for Lambda using either the Amazon VPC console or the AWS Command Line Interface (AWS CLI). For more information, see Creating an interface endpoint in the Amazon VPC User Guide. Open the Endpoints page of the Amazon VPC console. Choose Create Endpoint.

What is API endpoint in AWS?

An endpoint is the URL of the entry point for an AWS web service. The AWS SDKs and the AWS Command Line Interface (AWS CLI) automatically use the default endpoint for each service in an AWS Region. But you can specify an alternate endpoint for your API requests.

What is a lambda function url?

A function URL is a dedicated HTTP(S) endpoint for your Lambda function. You can create and configure a function URL through the Lambda console or the Lambda API. When you create a function URL, Lambda automatically generates a unique URL endpoint for you. Function URL endpoints have the following format:

How do I create an interface endpoint for Lambda?

You can create an interface endpoint for Lambda using either the Amazon VPC console or the AWS Command Line Interface (AWS CLI). For more information, see Creating an interface endpoint in the Amazon VPC User Guide .

How do I set up an API gateway in AWS Lambda?

Click the dotted-grey box and select API Gateway in the menu. Here you will select the API to use and how it will be invoked. If this is your first time using the API Gateway, AWS will setup a gateway titled LambdaMicroservice. AWS will also create a resource named /null which isn't ideal, but I'll show you how to change that later.

How do I make API requests to LAMBDA using private DNS?

If you enable private DNS for the interface endpoint, you can make API requests to Lambda using its default DNS name for the Region, for example, lambda.us-east-1.amazonaws.com. For more service endpoints, see Service endpoints and quotas in the AWS General Reference .


2 Answers

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"
like image 83
larschanders Avatar answered Oct 04 '22 13:10

larschanders


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.

like image 35
Jurgen Avatar answered Oct 04 '22 13:10

Jurgen