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