Vikram Patil
Vikram Patil

Reputation: 162

Multiple AWS API Gateway APIs as trigger to the same Lambda function

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 ?

Upvotes: 2

Views: 5089

Answers (2)

Biswa Bandhu Bhandary
Biswa Bandhu Bhandary

Reputation: 59

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.

Upvotes: 0

Ka Hou Ieong
Ka Hou Ieong

Reputation: 6515

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.

Upvotes: 2

Related Questions