class EventBus (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Events.EventBus |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsevents#EventBus |
![]() | software.amazon.awscdk.services.events.EventBus |
![]() | aws_cdk.aws_events.EventBus |
![]() | aws-cdk-lib » aws_events » EventBus |
Implements
IConstruct
, IDependable
, IResource
, IEvent
Define an EventBridge EventBus.
Example
const bus = new events.EventBus(this, 'bus', {
eventBusName: 'MyCustomEventBus',
description: 'MyCustomEventBus',
});
bus.archive('MyArchive', {
archiveName: 'MyCustomEventBusArchive',
description: 'MyCustomerEventBus Archive',
eventPattern: {
account: [Stack.of(this).account],
},
retention: Duration.days(365),
});
Initializer
new EventBus(scope: Construct, id: string, props?: EventBusProps)
Parameters
- scope
Construct
- id
string
- props
Event
Bus Props
Construct Props
Name | Type | Description |
---|---|---|
dead | IQueue | Dead-letter queue for the event bus. |
description? | string | The event bus description. |
event | string | The name of the event bus you are creating Note: If 'eventSourceName' is passed in, you cannot set this. |
event | string | The partner event source to associate with this event bus resource Note: If 'eventBusName' is passed in, you cannot set this. |
kms | IKey | The customer managed key that encrypt events on this event bus. |
deadLetterQueue?
Type:
IQueue
(optional, default: no dead-letter queue)
Dead-letter queue for the event bus.
description?
Type:
string
(optional, default: no description)
The event bus description.
The description can be up to 512 characters long.
eventBusName?
Type:
string
(optional, default: automatically generated name)
The name of the event bus you are creating Note: If 'eventSourceName' is passed in, you cannot set this.
eventSourceName?
Type:
string
(optional, default: no partner event source)
The partner event source to associate with this event bus resource Note: If 'eventBusName' is passed in, you cannot set this.
kmsKey?
Type:
IKey
(optional, default: Use an AWS managed key)
The customer managed key that encrypt events on this event bus.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
event | string | The ARN of the event bus, such as: arn:aws:events:us-east-2:123456789012:event-bus/aws.partner/PartnerName/acct1/repo1. |
event | string | The physical ID of this event bus resource. |
event | string | The policy for the event bus in JSON form. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
event | string | The name of the partner event source. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
eventBusArn
Type:
string
The ARN of the event bus, such as: arn:aws:events:us-east-2:123456789012:event-bus/aws.partner/PartnerName/acct1/repo1.
eventBusName
Type:
string
The physical ID of this event bus resource.
eventBusPolicy
Type:
string
The policy for the event bus in JSON form.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
eventSourceName?
Type:
string
(optional)
The name of the partner event source.
Methods
Name | Description |
---|---|
add | Adds a statement to the IAM resource policy associated with this event bus. |
apply | Apply the given removal policy to this resource. |
archive(id, props) | Create an EventBridge archive to send events to. |
grant | Grants an IAM Principal to send custom events to the eventBus so that they can be matched to rules. |
to | Returns a string representation of this construct. |
static from | Import an existing event bus resource. |
static from | Import an existing event bus resource. |
static from | Import an existing event bus resource. |
static grant | Permits an IAM Principal to send custom events to EventBridge so that they can be matched to rules. |
addToResourcePolicy(statement)
public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult
Parameters
- statement
Policy
Statement
Returns
Adds a statement to the IAM resource policy associated with this event bus.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
archive(id, props)
public archive(id: string, props: BaseArchiveProps): Archive
Parameters
- id
string
- props
Base
Archive Props
Returns
Create an EventBridge archive to send events to.
When you create an archive, incoming events might not immediately start being sent to the archive. Allow a short period of time for changes to take effect.
grantPutEventsTo(grantee)
public grantPutEventsTo(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grants an IAM Principal to send custom events to the eventBus so that they can be matched to rules.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromEventBusArn(scope, id, eventBusArn)
public static fromEventBusArn(scope: Construct, id: string, eventBusArn: string): IEventBus
Parameters
- scope
Construct
— Parent construct. - id
string
— Construct ID. - eventBusArn
string
— ARN of imported event bus.
Returns
Import an existing event bus resource.
static fromEventBusAttributes(scope, id, attrs)
public static fromEventBusAttributes(scope: Construct, id: string, attrs: EventBusAttributes): IEventBus
Parameters
- scope
Construct
— Parent construct. - id
string
— Construct ID. - attrs
Event
— Imported event bus properties.Bus Attributes
Returns
Import an existing event bus resource.
static fromEventBusName(scope, id, eventBusName)
public static fromEventBusName(scope: Construct, id: string, eventBusName: string): IEventBus
Parameters
- scope
Construct
— Parent construct. - id
string
— Construct ID. - eventBusName
string
— Name of imported event bus.
Returns
Import an existing event bus resource.
static grantAllPutEvents(grantee)
public static grantAllPutEvents(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
— The principal (no-op if undefined).
Returns
Permits an IAM Principal to send custom events to EventBridge so that they can be matched to rules.