Amazon EventBridge integration in Image Builder - EC2 Image Builder
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon EventBridge integration in Image Builder

Amazon EventBridge is a serverless event bus service that you can use to connect your Image Builder application with related data from other Amazon Web Services. In EventBridge, a rule matches incoming events and sends them to targets for processing. A single rule can send an event to multiple targets, and these events then run in parallel.

With EventBridge, you can automate your Amazon Web Services and respond automatically to system events such as application availability issues or resource changes. Events from Amazon Web Services are delivered to EventBridge in near real time. You can set up rules that react to incoming events to initiate actions. For example, sending an event to a Lambda function when the status of an EC2 instance changes from pending to running. These are called patterns. To create a rule based on an event pattern, see Creating Amazon EventBridge rules that react to events in the Amazon EventBridge User Guide.

Actions that can be automatically initiated include the following:

  • Invoke an Amazon Lambda function

  • Invoke Amazon EC2 Run Command

  • Relay the event to Amazon Kinesis Data Streams

  • Activate an Amazon Step Functions state machine

  • Notify an Amazon SNS topic or an Amazon SQS queue

You can also set up scheduling rules for the default event bus to perform an action at regular intervals, such as running an Image Builder pipeline to refresh an image on a quarterly basis. There are two types of schedule expressions:

  • cron expressions – The following example of a cron expression schedules a task to run every day at noon UTC+0:

    cron(0 12 * * ? *)

    For more information about using cron expressions with EventBridge, see Cron expressions in the Amazon EventBridge User Guide.

  • rate expressions – The following example of a rate expression schedules a task to run every 12 hours:

    rate(12 hour)

    For more information about using rate expressions with EventBridge, see Rate expressions in the Amazon EventBridge User Guide.

For more information about how EventBridge rules integrate with Image Builder image pipelines, see Use EventBridge rules with Image Builder pipelines.

Event messages that Image Builder sends

Image Builder sends event messages to EventBridge when there are significant changes in status for Image Builder resources. For example, when there's a state change for an image. The following examples show typical JSON event messages that Image Builder might send.

EC2 Image Builder Image State Change

Image Builder sends this event when the state changes for an image resource during image creation. For example, when the image status changes from one state to another, as follows:

  • From building to testing

  • From testing to distribution

  • From testing to failed

  • From integrating to available

{ "version": "0", "id": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "detail-type": "EC2 Image Builder Image State Change", "source": "aws.imagebuilder", "account": "111122223333", "time": "2024-01-18T17:50:56Z", "region": "us-west-2", "resources": ["arn:aws:imagebuilder:us-west-2:111122223333:image/cmkencryptedworkflowtest-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222/1.0.0/1"], "detail": { "previous-state": { "status": "TESTING" }, "state": { "status": "AVAILABLE" } } }
EC2 Image Builder CVE Detected

If you have CVE detection enabled for your image, Image Builder sends a message with the results whenever an image scan completes.

{ "version": "0", "id": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "detail-type": "EC2 Image Builder CVE Detected", "source": "aws.imagebuilder", "account": "111122223333", "time": "2023-03-01T16:59:09Z", "region": "us-east-1", "resources": [ "arn:aws:imagebuilder:us-east-1:111122223333:image/test-image/1.0.0/1", "arn:aws:imagebuilder:us-east-1:111122223333:image-pipeline/test-pipeline" ], "detail": { "resource-id": "i-1234567890abcdef0", "finding-severity-counts": { "all": 0, "critical": 0, "high": 0, "medium": 0 } } }
EC2 Image Builder Workflow Step Waiting

Image Builder sends a message when a WaitForAction workflow step pauses to wait for an asynchronous action to complete.

{ "version": "0", "id": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "detail-type": "EC2 Image Builder Workflow Step Waiting", "source": "aws.imagebuilder", "account": "111122223333", "time": "2024-01-18T16:54:44Z", "region": "us-west-2", "resources": ["arn:aws:imagebuilder:us-west-2:111122223333:image/workflowstepwaitforactionwithvalidsnstopictest-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222/1.0.0/1", "arn:aws:imagebuilder:us-west-2:111122223333:workflow/build/build-workflow-a1b2c3d4-5678-90ab-cdef-EXAMPLE33333/1.0.0/1"], "detail": { "workflow-execution-id": "wf-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "workflow-step-execution-id": "step-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "workflow-step-name": "TestAutoSNSStop" } }