Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test that an AWS EventBridge (or CloudWatch) Event Was Fired

I'm running some integration tests on a microservice I built in AWS. One of the tests is to assert that the service triggers an AWS EventBridge event, as downstream services will need to subscribe to this event.

My question is, how do I test this in the context of my mircroservice?

I need to just assert that the event was fired in AWS. I was hoping the AWS SDK would allow some way of asserting this e.g. being able to subscribe to an event on some long polling type operation, but haven't been able to find anything.

NOTE: Not looking for test double spy answers please. The level of testing I'm doing requires confirming that an actual event has been fired in AWS EventBridge

like image 961
GWed Avatar asked Mar 18 '20 16:03

GWed


People also ask

How do you test the CloudWatch event rule?

To test your ruleOpen the CloudWatch console at https://console.aws.amazon.com/cloudwatch/ . In the navigation pane, choose Events, Rules, select the name of the rule that you created, and choose Show metrics for the rule.

Is CloudWatch events the same as EventBridge?

EventBridge is the evolution of the CloudWatch Events service. It brings new features, including the ability to integrate data from popular SaaS providers as events within AWS.

Which AWS service will you use with your CloudWatch events to monitor the calls?

AWS CloudTrail enables you to monitor the calls made to the CloudWatch Events API for your account, including calls made by the AWS Management Console, the AWS CLI and other services.


1 Answers

You can create a rule for your specific event and target an SQS.

You can then read from the SQS (using long polling) and assert the event has fired.

like image 121
Radu Diță Avatar answered Oct 12 '22 23:10

Radu Diță