Events and automated actions for Amazon Braket with Amazon EventBridge - Amazon Braket

Events and automated actions for Amazon Braket with Amazon EventBridge

Amazon EventBridge monitors status change events in Amazon Braket tasks. Events from Amazon Braket are delivered to EventBridge, almost in real time. You can write simple rules that indicate which events interest you, including automated actions to take when an event matches a rule. Automatic actions that can be triggered include these:

  • Invoking an AWS Lambda function

  • Activating an AWS Step Functions state machine

  • Notifying an Amazon SNS topic

EventBridge monitors these Amazon Braket status change events:

  • The state of task changes

Amazon Braket guarantees delivery of task status change events. These events are delivered at least once, but possibly out of order.

For more information, see the Events and Event Patterns in EventBridge.

Monitor task status with EventBridge

With EventBridge, you can create rules that define actions to take when Amazon Braket sends notification of a status change regarding a Braket task. For example, you can create a rule that sends you an email message each time the status of a task changes.

  • Log in to AWS using an account that has permissions to use EventBridge and Amazon Braket.

  • Open the Amazon EventBridge console at https://console.aws.amazon.com/events/.

  • Choose Create rule.

  • Enter a Name for the rule, and, optionally, a description.

  • Under Define pattern choose Event pattern.

  • Under Event matching pattern, choose Custom pattern.

  • In the Event pattern box, add the following pattern and then choose Save.

    { "source": [ "aws.braket" ], "detail-type": [ "Braket Task State Change" ] }
  • In the Select event bus section, choose the event bus to use. If you have not created a custom event bus, choose AWS default event bus.

    Confirm that Enable the rule on the selected event bus is toggled on.

  • Under Select targets, choose the target action to take when a task state change event is received from Amazon Braket.

    For example, use an Amazon Simple Notification Service (SNS) topic to send an email or text message when an event occurs. To do that, first create an Amazon SNS topic using the Amazon SNS console. To learn more, see Using Amazon SNS for user notifications.

  • Optionally, choose Add target to specify an additional target action for the event rule.

  • Choose Create.

To capture all events from Amazon Braket, exclude the detail-type section as shown in the following code:

{ "source": [ "aws.braket" ] }

Example Amazon Braket event

The following example shows a task status change event:

{ "version": "0", "id": "foobar", "detail-type": "Braket Task State Change", "source": "aws.braket", "account": "foobar", "time": "2020-08-06T05:10:45Z", "region": "us-east-1", "resources": [ "foobar" ], "detail": { "quantumTaskArn": "foobar", "created": "foobar", "irType": "GA-MODEL", "shots": "100", "resultsS3ObjectKey": "Aug2020/sanity/24de4823-9688-4b7d-b916-32b547ab6454", "resultsS3Bucket": "braket-load-tests-013039061202", "modified": "foobar", "backendArn": "foobar", "status": "COMPLETED" } }