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

Can not link an existing API gateway as an event for a lambda resource using AWS SAM #2075

Closed
mooncrater31 opened this issue Jul 2, 2021 · 7 comments

Comments

@mooncrater31
Copy link

Description:

I am trying to create a SAM stack which creates a lambda. Now what I want is, to link an existing API gateway as a trigger for this lambda. So I tried to do this with the event :


Events:
        MyAPI:
          Type: Api
          Properties:
           Path: '/Prod/pushsfmessage'
           Method : post
           RestApiId: "l8lgze9uib"

Where "l8lgze9uib" is the API ID of the API I want to link. This gives me an error :
"StatusReason": "Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [<lambda-name>] is invalid. Event with id [MyAPI] is invalid. RestApiId must be a valid reference to an 'AWS::Serverless::Api' resource in same template.",

Which means that I can not use an API that doesn't exist in the template. Which would mean that I am required to create the API gateway every time I deploy the stack, which doesn't solve my issue.

Steps to reproduce:

Try to link any external API gateway as a trigger to a lambda resource.

Observed result:

Error in creating the lambda trigger.

Expected result:

No issue, and the trigger is created. Just like we can link existing DDB streams with lambdas.

@wchengru
Copy link
Contributor

wchengru commented Jul 4, 2021

Hi @mooncrater31 , SAM is not supporting referring to an external API gateway not. To help us understanding the necessary of this feature, can you please let us know the use case you want to create an API gateway not existing in the template?
If you are using the nested stack, you can still use an API resource which is in the root stack: #1337 (comment)

@sivanaikk
Copy link

There's an existing API Gate way which is created from AWS Console and It contains multiple routes and We want to save our resources and time by attaching the existing API Gateway to SAM.

@RaphaelHerd
Copy link

I also require that. I cannot understand why this is not the default. Creating new apps from scratch is not the common use case. Most applications are already running (brown field) and they will be migrated step by step. In serverless framework, this works for a long time. Only reason I gave SAM a try is because of its good debugging possibilities. For me, SAM seems not ready for enterprise usage yet.

@jkoziol
Copy link

jkoziol commented Aug 12, 2022

This would also be helpful in order to create api gateway within one stack, and create multiple lambda (each with its own stack/repository) and link all those lambdas into one gateway. To have structure in apigateway like:
myapi.com/someapi -> lambda1
myapi.com/othereapi -> lambda2
...

@ggatti-orangeloops
Copy link

Any update on this? I'm facing the same issue right now. Thanks.

@gfernandescs
Copy link

I also encountered the same problem. This feature would be very useful

@hoffa
Copy link
Contributor

hoffa commented Jan 31, 2023

Resolving in favor of #2734

@hoffa hoffa closed this as completed Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants