EventBus¶
-
class
aws_cdk.aws_events.
EventBus
(scope, id, *, event_bus_name=None, event_source_name=None)¶ Bases:
aws_cdk.core.Resource
Define an EventBridge EventBus.
- ExampleMetadata
infused
- Resource
AWS::Events::EventBus
Example:
bus = events.EventBus(self, "bus", event_bus_name="MyCustomEventBus" ) bus.archive("MyArchive", archive_name="MyCustomEventBusArchive", description="MyCustomerEventBus Archive", event_pattern=events.EventPattern( account=[Stack.of(self).account] ), retention=Duration.days(365) )
- Parameters
scope (
Construct
) –id (
str
) –event_bus_name (
Optional
[str
]) – The name of the event bus you are creating Note: If ‘eventSourceName’ is passed in, you cannot set this. Default: - automatically generated nameevent_source_name (
Optional
[str
]) – The partner event source to associate with this event bus resource Note: If ‘eventBusName’ is passed in, you cannot set this. Default: - no partner event source
Methods
-
apply_removal_policy
(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
).- Parameters
policy (
RemovalPolicy
) –- Return type
None
-
archive
(id, *, event_pattern, archive_name=None, description=None, retention=None)¶ 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.
- Parameters
id (
str
) –event_pattern (
EventPattern
) – An event pattern to use to filter events sent to the archive.archive_name (
Optional
[str
]) – The name of the archive. Default: - Automatically generateddescription (
Optional
[str
]) – A description for the archive. Default: - noneretention (
Optional
[Duration
]) – The number of days to retain events for. Default value is 0. If set to 0, events are retained indefinitely. Default: - Infinite
- Return type
-
grant_put_events_to
(grantee)¶ Grants an IAM Principal to send custom events to the eventBus so that they can be matched to rules.
- Parameters
grantee (
IGrantable
) –- Return type
-
to_string
()¶ Returns a string representation of this construct.
- Return type
str
Attributes
-
env
¶ 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.
- Return type
-
event_bus_arn
¶ aws:events:us-east-2:123456789012:event-bus/aws.partner/PartnerName/acct1/repo1.
- Type
The ARN of the event bus, such as
- Type
arn
- Return type
str
-
event_bus_name
¶ The physical ID of this event bus resource.
- Return type
str
-
event_bus_policy
¶ The policy for the event bus in JSON form.
- Return type
str
-
event_source_name
¶ The name of the partner event source.
- Return type
Optional
[str
]
-
node
¶ The construct tree node associated with this construct.
- Return type
Static Methods
-
classmethod
from_event_bus_arn
(scope, id, event_bus_arn)¶ Import an existing event bus resource.
-
classmethod
from_event_bus_attributes
(scope, id, *, event_bus_arn, event_bus_name, event_bus_policy, event_source_name=None)¶ Import an existing event bus resource.
- Parameters
scope (
Construct
) – Parent construct.id (
str
) – Construct ID.event_bus_arn (
str
) – The ARN of this event bus resource.event_bus_name (
str
) – The physical ID of this event bus resource.event_bus_policy (
str
) – The JSON policy of this event bus resource.event_source_name (
Optional
[str
]) – The partner event source to associate with this event bus resource. Default: - no partner event source
- Return type
-
classmethod
from_event_bus_name
(scope, id, event_bus_name)¶ Import an existing event bus resource.
-
classmethod
grant_all_put_events
(grantee)¶ Permits an IAM Principal to send custom events to EventBridge so that they can be matched to rules.
- Parameters
grantee (
IGrantable
) – The principal (no-op if undefined).- Return type
-
classmethod
grant_put_events
(grantee)¶ (deprecated) Permits an IAM Principal to send custom events to EventBridge so that they can be matched to rules.
- Parameters
grantee (
IGrantable
) – The principal (no-op if undefined).- Deprecated
use grantAllPutEvents instead
- Stability
deprecated
- Return type
-
classmethod
is_construct
(x)¶ Return whether the given object is a Construct.
- Parameters
x (
Any
) –- Return type
bool
-
classmethod
is_resource
(construct)¶ Check whether the given construct is a Resource.
- Parameters
construct (
IConstruct
) –- Return type
bool