Trigger a lambda function after a rest api is accessed

0 votes
I use a rest API in the Aws api gateway to retrieve data from an external http endpoint.

I need to start a lambda function that consumes the data supplied by the rest api every time this rest api is accessed and returns data. How can I go about doing that?

I've tried searching for answers, and every single one of them points to the use of a rest API to start a lambda function.
Feb 14, 2023 in AWS by Ashwini
• 5,430 points
825 views

1 answer to this question.

0 votes

To trigger a Lambda function after a REST API is accessed via API Gateway, you can use an integration type of "Lambda Function" in your API Gateway resource.

Here are the steps you can follow to configure the integration:

  1. Create your Lambda function that will consume the data supplied by the REST API. This function can be written in any supported language and should be configured to process the data from the REST API.

  2. In the AWS Management Console, open the API Gateway service and create a new API or select an existing one.

  3. Create a new resource for the endpoint that retrieves data from the external HTTP endpoint.

  4. Create a new method for the resource and select the HTTP method (GET, POST, etc.) used to retrieve data from the external HTTP endpoint.

  5. In the Integration section of the method configuration, select "Lambda Function" as the Integration Type.

  6. Choose the region where your Lambda function is located and select the Lambda function you created earlier.

  7. In the Mapping Templates section, choose "When there are no templates defined (recommended)".

  8. Click "Save" to create the API Gateway method.

  9. Deploy your API to a stage so that it can be accessed via a public URL.

  10. Create a new trigger for your Lambda function. You can do this from the Lambda console by selecting your function, clicking "Add Trigger", and selecting "API Gateway".

  11. Select the API Gateway you created and the stage you deployed it to.

With these steps, your Lambda function will be triggered every time the REST API endpoint is accessed. The Lambda function will receive the data from the REST API as an event object, which you can process and consume as needed.

Elevate Your Expertise with Microservices Software Architecture Certification Training!

answered Feb 16, 2023 by anonymous

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

What is the service limit of a Lambda function?

This table will help you understand the ...READ MORE

answered Mar 5, 2019 in AWS by Ravi
900 views
0 votes
1 answer

Add a new item to a Dynamodb using a AWS lambda function each time a function is executed with Cloudwatch

The problem here is that the PutItem ...READ MORE

answered Feb 14, 2022 in AWS by Rahul
• 2,120 points
597 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Unable to create a function in Lambda.

Hey @Jino, the error that you are ...READ MORE

answered Dec 20, 2018 in AWS by Shuvodip
1,165 views
0 votes
1 answer

How to delete a lambda function?

You can simply do it from the ...READ MORE

answered Dec 21, 2018 in AWS by Nabarupa
3,436 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP