-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
The ApiGateway
target in aws-events-targets requires a RestApi
from aws-apigateway as part of the constructor. This is actually too restrictive and, as far as I can tell, the implementation does not require that particular subclass. The inheritance hierarchy in aws-apigateway is as follows. The current requirements preclude using a SpecRestApi
as a target, without good reason.
export class SpecRestApi extends RestApiBase {}
export class RestApi extends RestApiBase {}
export abstract class RestApiBase extends Resource implements IRestApi {}
The implementation of ApiGateway
makes use of this.restApi.arnForExecuteApi()
and this.restApi.deploymentStage.stageName
, both of which are defined in IRestApi
.
Reproduction Steps
const swaggerDefinition = getSwaggerDefinition(...);
this.api = new SpecRestApi(this, "RestApi", {
apiDefinition: ApiDefinition.fromInline(swaggerDefinition),
})
// @ts-ignore
let uglyHack : RestApi = this.api;
const event_bridge_rule = new Rule(this, "EventBridgeRule", {
eventPattern: {source: ["aws.ecs"], detailType: ["ECS Task State Change"]},
targets: [new ApiGateway(uglyHack, {....})]
})
What did you expect to happen?
The ApiGateway
target from aws-events-targets should accept an IRestApi
so that a Rest API built from a swagger or OpenAPI definition can be used as a target for an Event Bridge Rule.
What actually happened?
Only RestApi
are accepted, so I'm precluded from using a SpecRestApi
, which is a sibling to RestApi
.
Environment
- CDK CLI Version : 1.120.0
- Framework Version: 1.120.0
- Node.js Version: v12.22.6
- OS : all
- Language (Version): all
This is 🐛 Bug Report