Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing API Gateway API when adding Lambda Api Trigger #232

Closed
Palisand opened this issue Dec 15, 2017 · 2 comments
Closed

Use existing API Gateway API when adding Lambda Api Trigger #232

Palisand opened this issue Dec 15, 2017 · 2 comments

Comments

@Palisand
Copy link

Is it possible to add an ApiTrigger event or resource (to a Lambda Function) that adds a new endpoint to an existing API Gateway API?

Rather than having to create a new API whenever I deploy a single function, I would like to be able to create a new resource in an existing API that serves as a lambda trigger.

@sanathkr
Copy link
Contributor

sanathkr commented Jan 8, 2018

This is unfortunately not possible. See #249 and +1 there if you want it :)

@sanathkr sanathkr closed this as completed Jan 8, 2018
@Harfel94
Copy link

Harfel94 commented Sep 9, 2019

I'm a little late to write this reply, but the thing you want to do is possible. I don't know if you have a single template for your lambda functions or you create a new one for every function you deploy, but the idea is the same either way: have your API gateway and lambda permissions in a separate template from your lambda functions.

The SAM properties of an API gateway resource allow you to define the structure of your API gateway using OpenAPI, which I think gives you more control. Among many other things, OpenAPI allows you to integrate lambda as the backend for your API methods. Once you do that, you need to provide your API Gateway with permission to call your lambda functions. You do that by using the AWS::Lambda::Permission resource from CloudFormation.

The advantage of this approach is everytime you create a new Lambda function you can integrate it to your existing API gateway instead of letting SAM create a new one. All you have to do is add the path, method and integration to your API Gateway template as well as a new permission for the new lambda function. The disadvantage that resources that SAM creates implicitly such as the lambda permissions and API configuration must be configured explicitly by you.

If you are still interested in an answer I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants