2
votes

I already had an API Gateway API as the trigger for my AWS Lambda function. However when I tried to add another API as a trigger to the same AWS Lambda, it threw an error saying that

There was an error creating the trigger: An integration is already present on this method.

Even when I delete the trigger already present from the configuration window of Lambda, it still shows that the trigger is present. How can I add multiple API Gateway APIs as triggers for the same lambda function ?

2
I believe an API Gateway Endpoint can only be used with a single Lambda integration. However didn't find any explicit document stating the same.Amod Gokhale
All you may need to do is change the name of the api when you set the trigger. Probably you are using the same name that you used previously and it come pre-populated, so likely to get unnoticed.Mangesh Borkar
You can delete the API Gateway trigger from the Lambda interface, but it seems like you still actually have to go to the API Gateway interface and delete the method that was calling your function there too. I had to do this when creating a new version of my function and tried to attach API Gateway to it again.jket

2 Answers

2
votes

You can setup it via API Gateway console.

  • Create the Lambda function via Lambda without providing a trigger
  • Go to API Gateway Console
  • Create an API.
  • Create a resource and method
  • Select the Lambda function you want to trigger by the method
  • Create an other API/method
  • Select the Lambda function you want to trigger by the method

Since you are creating the trigger/integration via API Gateway Console, API Gateway will setup the proper permission to allow API Gateway to invoke your Lambda function on multiple APIs/methods.

0
votes

In the API Gateway, we cannot make entries with the same resource name. When you have created a trigger it's already created and again you are trying to create another one. So we have to clear the previous one and then try again or else we can update it going into the API Gateway interface.