You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(apigatewayv2): integration class does not render an integration resource (#17729)
Routes on APIGateway V2 can integrate with different backends. This is
achieved by creating the CFN resource `AWS::ApiGatewayV2::Integration`
that is then referenced in the resource for the Route.
Currently, the `IHttpRouteIntegration` (and `IWebSocketRouteIntegration`)
interface represents a unique backend that a route can integrate with,
using the CDK "bind" pattern.
An integration can be bound to any number of routes but should be
rendered into a single instance of `AWS::ApiGatewayV2::Integration`
resource.
To achieve this currently, the `HttpApi` (and `WebSocketApi`) class
holds a cache of all integrations defined against its routes.
This is the wrong level of caching and causes a number of problems.
1. We rely on the configuration of the `AWS::ApiGateway::Integration`
resource to determine if one already exists.
This means that two instances of `IHttpRouteIntegration` can result
in rendering only one instance of `AWS::ApiGateway::Integration`
resource.
Users may want to intentionally generate multiple instances of
`AWS::ApiGateway::Integration` classes with the same configuration.
Taking away this power with CDK "magic" is just confusing.
2. Currently, we allow using the same instance of
`IHttpRouteIntegration` (or `IWebSocketRouteIntegration`) to be bound
to routes in different `HttpApi`. When bound to the route, the CDK
renders an instance of `AWS::ApiGatewayV2::Integration` for each API.
This is another "magic" that has the potential for user confusion and
bugs.
The solution is to KeepItSimple™.
Remove the API level caching and simply cache at the level of each
integration. This ensures that each instance of `HttpRouteIntegration`
(previously `IHttpRouteIntegration`) renders to exactly one instance of
`AWS::ApiGatewayV2::Integration`.
Disallow using the same instance of `HttpRouteIntegration` across
different instances of `HttpApi`.
fixes#13213
BREAKING CHANGE: The interface `IHttpRouteIntegration` is replaced by
the abstract class `HttpRouteIntegration`.
* **apigatewayv2:** The interface `IWebSocketRouteIntegration` is now
replaced by the abstract class `WebSocketRouteIntegration`.
* **apigatewayv2:** Previously, we allowed the usage of integration
classes to be used with routes defined in multiple `HttpApi` instances
(or `WebSocketApi` instances). This is now disallowed, and separate
instances must be created for each instance of `HttpApi` or
`WebSocketApi`.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
0 commit comments