-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(apigatewayv2-integrations): add PutEvents support for EventBridge integration #35766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(apigatewayv2-integrations): add PutEvents support for EventBridge integration #35766
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
* | ||
* @default HttpIntegrationSubtype.EVENTBRIDGE_PUT_EVENTS | ||
*/ | ||
readonly subtype?: apigwv2.HttpIntegrationSubtype; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we fix the HttpIntegrationSubtype.EVENTBRIDGE_PUT_EVENTS
? Otherwise, you could pass another subtype here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that’s another valid approach. Keeping it this way allows us to easily extend support to other subtypes in the future.
If an unknown subtype is provided, we already handle it by throwing an error, so that scenario is covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I understand.
But from the DX-perspective the developer does not know that only HttpIntegrationSubtype.EVENTBRIDGE_PUT_EVENTS
is possible.
Perhaps you could create a new type
type HttpEventBridgeIntegrationSubtype = 'EVENTBRIDGE_PUT_EVENTS' // then you could use a discreminator to add more events;
export interface HttpEventBridgeIntegrationProps {
// ..
readonly subtype?: HttpEventBridgeIntegrationSubtype;
// ...
}
export class HttpEventBridgeIntegration extends apigwv2.HttpRouteIntegration {
private readonly subtype: apigwv2.HttpIntegrationSubtype;
/**
* @param id id of the underlying integration construct
* @param props properties to configure the integration
*/
constructor(
id: string,
private readonly props: HttpEventBridgeIntegrationProps,
) {
super(id);
this.subtype = this.props.subtype;
}
public bind(options: apigwv2.HttpRouteIntegrationBindOptions): apigwv2.HttpRouteIntegrationConfig {
// ...
return {
payloadFormatVersion: apigwv2.PayloadFormatVersion.VERSION_1_0,
type: apigwv2.HttpIntegrationType.AWS_PROXY,
subtype: apigwv2.HttpIntegrationSubtype[this.props.subtype ?? 'EVENTBRIDGE_PUT_EVENTS'], // <-- this needs to be changes
credentials: apigwv2.IntegrationCredentials.fromRole(invokeRole),
connectionType: apigwv2.HttpConnectionType.INTERNET,
parameterMapping: this.props.parameterMapping ?? this.createDefaultParameterMapping(options.scope),
};
}
}
@jasdeepbhalla Ah, you were faster than me :D |
Issue #35714
Closes #35714
Reason for this change
The CDK currently lacks a high-level L2 construct to enable HTTP API integration with EventBridge
PutEvents
. Users must manually configure the integration, including IAM roles and parameter mapping, which adds complexity and potential for misconfiguration. This feature simplifies usage and aligns with other existing HTTP API integrations like SQS.Description of changes
HttpEventBridgeIntegration
class extendingHttpRouteIntegration
.HttpEventBridgeIntegrationProps
interface with required parameters:detail
,detailType
,source
; and optional parameters:eventBusName
,resources
,time
,region
,traceHeader
,invocationRole
,description
,timeout
.invocationRole
is not provided.Example usage:
Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license