AwsEventbridge
Service-level AWS EventBridge component.
Remarks
Supported capabilities:
scheduler— creates an EventBridge Scheduler schedule via AwsEventbridgeScheduler.eventBus— creates an EventBridge event bus (and optional resource-based policy) via AwsEventbridgeEventBus.eventRule— creates an EventBridge rule with optional targets via AwsEventbridgeEventRule.pipe— creates an EventBridge Pipe connecting a source to a target via AwsEventbridgePipe.connection— creates an EventBridge Connection for API Destination authentication via AwsEventbridgeConnection.defaultEventBus— creates the standard project-and-environment EventBridge event bus.
Schedule groups are created separately through AwsEventbridgeScheduleGroup and reused by schedules via scheduler.groupName.
Naming:
- Root type
${namespace}:aws:AwsEventbridgeselects capabilityeventbridge-scheduler,eventbridge-event-bus,eventbridge-event-rule,eventbridge-pipe,eventbridge-connection, oreventbridge-default-event-busfrom the active union arm. Its SHARED logical/provider identity comes from that arm'sname, ordefaultEventBus.identity; target${env}-${projectHash}-<selected-capability>-${sanitiseNamePart(identity)}. - Each selected capability is an independently constructible root using its own
args.name; the facade never supplies a positional identity. Their provider children use the raw capabilityargs.nameas their sole child discriminator. - Event bus, event rule, connection, pipe and scheduler AWS names use the
stackAndPurposestyle${env}-${projectHash}-<purpose>. - The default event bus uses the fixed
eventspurpose withstackAndPurpose, yielding${env}-${projectHash}-events. - Event-bus policies and event targets set no standalone AWS name (targets use their
targetId).
Example
const hourlySync = new AwsEventbridge({
scheduler: {
name: 'hourlySync',
scheduleExpression: 'rate(1 hours)',
flexibleTimeWindow: { mode: 'OFF' },
target: {
arn: myQueue.arn,
roleArn: schedulerRole.arn,
},
description: 'Triggers hourly data sync',
},
});
export const scheduleArn = hourlySync.scheduler?.arn;const backupGroup = new AwsEventbridgeScheduleGroup({
name: 'ceGithubBackup',
});
const backupTrigger = new AwsEventbridge({
scheduler: {
name: 'triggerBackup',
groupName: backupGroup.name,
scheduleExpression: 'cron(0 4 ? * * *)',
flexibleTimeWindow: { mode: 'OFF' },
target: {
arn: stateMachineArn,
roleArn: schedulerRole.arn,
},
},
});
export const backupScheduleArn = backupTrigger.scheduler?.arn;const defaultBus = new AwsEventbridge({
defaultEventBus: {
identity: 'events',
},
});const orderRule = new AwsEventbridge({
eventRule: {
name: 'orderEvents',
defaultEventBus: defaultBus.defaultEventBus!,
eventPattern: JSON.stringify({
source: ['myapp.orders'],
'detail-type': ['OrderPlaced'],
}),
targets: { processOrder: { lambda: { function: processOrderFn } } },
},
});
export const ruleArn = orderRule.eventRule?.arn;const auditBus = new AwsEventbridge({
eventBus: { name: 'auditEvents' },
});
const auditRule = new AwsEventbridge({
eventRule: {
name: 'auditEvents',
eventBus: auditBus.eventBus!,
eventPattern: JSON.stringify({ source: ['myapp.audit'] }),
},
});const ordersForwarder = new AwsEventbridge({
pipe: {
name: 'ordersForwarder',
iamRole: pipeRole.arn,
source: sourceQueue.arn,
target: targetQueue.arn,
description: 'Routes order events from SQS to SQS',
sourceParameters: {
sqsQueue: { batchSize: 10 },
},
},
});
export const pipeArn = ordersForwarder.pipe?.arn;const apiConn = new AwsEventbridge({
connection: {
name: 'myApiConn',
authorizationType: 'API_KEY',
authParameters: {
apiKey: { key: 'x-api-key', value: 'supersecret' },
},
},
});
export const connArn = apiConn.connection?.arn;Constructors
new AwsEventbridge(
args: AwsEventbridgeArgs,
options?: ComponentResourceOptions,
): AwsEventbridge
Parameters
args(AwsEventbridgeArgs) — Service-level EventBridge capability inputs.The component logical name is derived from the selected capability name field as${environmentCode}-${projectHash}-eventbridge-${sanitisedIdentity}.Capability identity fields must be non-empty synchronous plain strings and are validated fail-fast before any resources are created.options(ComponentResourceOptions, optional) — Optional settings controlling resource behaviour.
Returns
AwsEventbridge
Hierarchy
ComponentResourceAwsEventbridge
Properties
connection: AwsEventbridgeConnection
Optional EventBridge Connection capability created by this component.
defaultEventBus: AwsEventbridgeDefaultEventBus
Optional standard EventBridge event bus created for this project and environment.
eventBus: AwsEventbridgeEventBus
Optional EventBridge Event Bus capability created by this component.
eventRule: AwsEventbridgeEventRule
Optional EventBridge Event Rule capability created by this component.
pipe: AwsEventbridgePipe
Optional EventBridge Pipe capability created by this component.
scheduler: AwsEventbridgeScheduler
Optional EventBridge Scheduler capability created by this component.
urn: Output<string>
Inherited from urn
The stable logical URN used to distinctly address a resource, both before and after deployments.
Methods
getData(): Promise<any>
Inherited from getData
Retrieves the data produces by initialize. The data is immediately available in a derived class's constructor after the super(...) call to ComponentResource.
Returns
Promise<any>
getProvider(moduleMember: string): ProviderResource | undefined
Inherited from getProvider
Returns the provider for the given module member, if one exists.
Parameters
moduleMember(string)
Returns
ProviderResource | undefined
initialize(
args: Inputs,
opts?: ComponentResourceOptions,
name?: string,
type?: string,
): Promise<any>
Inherited from initialize
Can be overridden by a subclass to asynchronously initialize data for this component automatically when constructed. The data will be available immediately for subclass constructors to use. To access the data use getData.
Parameters
args(Inputs)opts(ComponentResourceOptions, optional)name(string, optional)type(string, optional)
Returns
Promise<any>
registerOutputs(
outputs?: Inputs | Promise<Inputs> | Output<Inputs>,
): void
Inherited from registerOutputs
Registers synthetic outputs that a component has initialized, usually by allocating other child sub-resources and propagating their resulting property values.
Component resources can call this at the end of their constructor to indicate that they are done creating child resources. This is not strictly necessary as this will automatically be called after the initialize method completes.
Parameters
outputs(Inputs | Promise<Inputs> | Output<Inputs>, optional)
Returns
void
Static Methods
isInstance(obj: any): obj is ComponentResource<any>
Inherited from isInstance
Returns true if the given object is a CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.
Parameters
obj(any)
Returns
obj is ComponentResource<any>