(apigateway): support deployment salting for imported RestApi #26668
Labels
@aws-cdk/aws-apigateway
Related to Amazon API Gateway
effort/large
Large work item – several weeks of effort
feature-request
A feature should be added or improved.
p1
Describe the feature
This is a continuation of the discussion in the (already closed) ticket: #12417
Having an API Gateway and its routes spread out across CDK/CloudFormation stacks is a good idea for a variety of reasons:
Use Case
A moderately sized API Gateway with a few dozens of Resources and Methods inside, quickly exhausts the 500 resources limit of CloudFormation.
This is mostly because of the fact that every Resource and Method is composed of multiple sub-resources like, the Lambda, some IAM roles, CloudWatch LogGroup, Retention Policies to that LogGroup, etc, etc. So reaching the 500 count is very easy.
Proposed Solution
The main reason why the previous ticket was closed was because the
new Deployment()
resource has no way of knowing when and if it should be redeployed, considering that routes (Resources and Methods) were possibly added by a different stack.The reason why the
new Deployment()
is conditionally recreated properly when everything is in the same stack, is because the Resources and Methods can be attached as "dependencies" to the Deployment construct, so it is invalidated as soon as a Resource or Method is added or removed.My proposal here is simple - develop a Custom Resource (Lambda) that internally queries the state of the API Gateway (collect all current Resources and Methods) and hashes them to a stable string. That string can then be used as a singular dependency to the
new Deployment()
construct, causing it to be recreated conditionally, only when the hash changes.Here's a typical structure based on current recommendations:
Stack A:
What people want (me included):
Stack A:
Stack B:
Stack C:
The solution I'm proposing would change Stack C, to something like this (pseudo code):
Other Information
No response
Acknowledgements
CDK version used
2.90.0
Environment details (OS name and version, etc.)
MacOS
The text was updated successfully, but these errors were encountered: