class EventBus (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Events.EventBus |
Java | software.amazon.awscdk.services.events.EventBus |
Python | aws_cdk.aws_events.EventBus |
TypeScript (source) | @aws-cdk/aws-events » EventBus |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IEvent
Define an EventBridge EventBus.
Example
const bus = new events.EventBus(this, 'bus', {
eventBusName: '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 |
---|---|---|
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. |
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.
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 | Construct | The construct tree node associated with this construct. |
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:
Construct
The construct tree node associated with this construct.
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 |
---|---|
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. |
static grant | Permits an IAM Principal to send custom events to EventBridge so that they can be matched to rules. |
RemovalPolicy(policy)
applypublic 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.
PutEventsTo(grantee)
grantpublic 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.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
EventBusArn(scope, id, eventBusArn)
static frompublic 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.
EventBusAttributes(scope, id, attrs)
static frompublic 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.
EventBusName(scope, id, eventBusName)
static frompublic 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.
AllPutEvents(grantee)
static grantpublic 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.
PutEvents(grantee)
static grantpublic static grantPutEvents(grantee: IGrantable): Grant
⚠️ Deprecated: use grantAllPutEvents instead
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.