-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Real-Life-IaC/use-eventbridge-instead-of-sns
Merge use-eventbridge-instead-of-sns
- Loading branch information
Showing
5 changed files
with
126 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import aws_cdk as cdk | ||
|
||
from aws_cdk import aws_events as events | ||
from aws_cdk import aws_eventschemas as schemas | ||
from aws_cdk import aws_ssm as ssm | ||
from constructs import Construct | ||
|
||
|
||
class B1EventBus(Construct): | ||
"""Event Bus for PubSub""" | ||
|
||
def __init__( | ||
self, | ||
scope: Construct, | ||
id: str, | ||
) -> None: | ||
super().__init__(scope, id) | ||
|
||
# Create Event Bus | ||
self.event_bus = events.EventBus( | ||
scope=self, | ||
id="EventBus", | ||
) | ||
|
||
# Create an archive for the event bus | ||
self.event_bus.archive( | ||
id="Archive", | ||
description="PubSub Archive", | ||
event_pattern=events.EventPattern( | ||
account=[cdk.Aws.ACCOUNT_ID] | ||
), | ||
retention=cdk.Duration.days(90), | ||
) | ||
|
||
# Allows EventBridge to automatically discover schemas | ||
schemas.CfnDiscoverer( | ||
scope=self, | ||
id="EventSchemaDiscoverer", | ||
source_arn=self.event_bus.event_bus_arn, | ||
description="PubSub Event Schema Discoverer", | ||
) | ||
|
||
# Export to SSM | ||
ssm.StringParameter( | ||
scope=self, | ||
id="EventBusArn", | ||
parameter_name="/pubsub/event-bus/arn", | ||
string_value=self.event_bus.event_bus_arn, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.