-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(aws-events): ApiDestination missing fromArn methods for existing API destinations #29942
Description
Describe the bug
ApiDestination doesn't have any way to reference an existing EventBridge API destination:
aws-cdk/packages/aws-cdk-lib/aws-events/lib/api-destination.ts
Lines 70 to 107 in f00f918
| export class ApiDestination extends Resource implements IApiDestination { | |
| /** | |
| * The Connection to associate with Api Destination | |
| */ | |
| public readonly connection: IConnection; | |
| /** | |
| * The Name of the Api Destination created. | |
| * @attribute | |
| */ | |
| public readonly apiDestinationName: string; | |
| /** | |
| * The ARN of the Api Destination created. | |
| * @attribute | |
| */ | |
| public readonly apiDestinationArn: string; | |
| constructor(scope: Construct, id: string, props: ApiDestinationProps) { | |
| super(scope, id, { | |
| physicalName: props.apiDestinationName, | |
| }); | |
| this.connection = props.connection; | |
| let apiDestination = new CfnApiDestination(this, 'ApiDestination', { | |
| connectionArn: this.connection.connectionArn, | |
| description: props.description, | |
| httpMethod: props.httpMethod ?? HttpMethod.POST, | |
| invocationEndpoint: props.endpoint, | |
| invocationRateLimitPerSecond: props.rateLimitPerSecond, | |
| name: this.physicalName, | |
| }); | |
| this.apiDestinationName = this.getResourceNameAttribute(apiDestination.ref); | |
| this.apiDestinationArn = apiDestination.attrArn; | |
| } | |
| } |
This is problematic because the aws-events-targets.ApiDestination expects an aws-events.ApiDestination:
| private readonly apiDestination: events.IApiDestination, |
I would like to have multiple Rules targeting the same (existing) ApiDestination. In my case the API destination is a Slack webhook with a secret in the URL endpoint.
Expected Behavior
To be able to reference an existing API destination by an ARN, like in Connection:
| public static fromEventBusArn(scope: Construct, id: string, connectionArn: string, connectionSecretArn: string): IConnection { |
Or Eventbus:
| public static fromEventBusArn(scope: Construct, id: string, eventBusArn: string): IEventBus { |
Current Behavior
No method to reference existing EventBridge API destination by ARN.
Reproduction Steps
Try to import existing API destination.
Possible Solution
Add ImportedApiConnection and method.
Additional Information/Context
No response
CDK CLI Version
2.138.0
Framework Version
No response
Node.js Version
20
OS
Sonoma
Language
Python
Language Version
No response
Other information
No response