What's the correct way to structure a large API Gateway using AWS SAM nested applications?
Asked Answered
T

0

10

I have an API with around 150 endpoints. When I try to deploy the whole thing in one SAM (Serverless Application Model) template it fails (expected) because the 744 resources it wants to create is greater than the maximum allowed 200.

I broke the app up into a default template that creates the serverless API and a default route and Lambda function, and placed the grouped functions in their own templates, uploaded to S3 and referenced them in aws::serverless::application (nested stacks) passing in a reference to the API Gateway created in the default template.

Much to my surprise, it fails with the error:

RestApiId must be a valid reference to an 'AWS::Serverless::Api' resource in same template

In the same template?! Is it impossible to use nested applications to get around the 200 resource limit and not be forced to create multiple API gateway instances?

UPDATE:

It looks like this issue has been noted by the SAM developers and there is an issue and RFC in progress to resolve (both open issues as of May 5, 2019):

https://github.com/awslabs/serverless-application-model/issues/349 https://github.com/awslabs/serverless-application-model/issues/866

UPDATE OCT 2021:

Over two years later the above issues in GitHub are still open

Trapp answered 5/5, 2019 at 13:6 Comment(5)
If you believe those GitHub issues answer the question you asked, perhaps move them to be an answer so that we can close out this question?Aplanospore
They don’t answer the question because they are not yet resolved and are only in the RFC stage.Trapp
Sure but if you're saying that your issue is tracked in those GitHub issues, then this question here is answered isn't it? Or, did you mean that you remain hopeful that someone might give you a different answer here? If so, no problem.Aplanospore
I think there’s value in keeping the question open in case others have come up with workarounds (and I could use one) but I’ll add an answer when I hear word of a pull request so that people finding this question have a clear solution right here.Trapp
Got it, no problem.Aplanospore

© 2022 - 2024 — McMap. All rights reserved.