Skip to content

Instantly share code, notes, and snippets.

@wenqiglantz
Created January 29, 2022 01:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wenqiglantz/147d0f77f448ce636dd66b4d4094b740 to your computer and use it in GitHub Desktop.
Save wenqiglantz/147d0f77f448ce636dd66b4d4094b740 to your computer and use it in GitHub Desktop.
AmazonEventBridge client = AmazonEventBridgeClient.builder()
.withRegion(Regions.US_EAST_1)
.withCredentials(new DefaultAWSCredentialsProviderChain())
.build();
PutEventsRequestEntry requestEntry = new PutEventsRequestEntry();
requestEntry.withSource("customer-service") //this needs to match the event pattern defined in step 4 below
.withDetailType("customer-created-detail-type") //this needs to match the event pattern defined in step 4 below
.withDetail(toJson(customerWasCreated)) //this converts the event object into JSON string
.withEventBusName("test-event-bus"); //this needs to match the custom event bus name created in step 4 below
PutEventsRequest request = new PutEventsRequest();
request.withEntries(requestEntry);
PutEventsResult result = client.putEvents(request); //AmazonEventBridgeClient puts the event onto the event bus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment