Lesson 2 of 3 Event-Driven Automation

Applying EventBridge Automation Patterns

This lesson explains the EventBridge patterns that repeatedly appear in operations questions, connecting AWS events to automated responses, and how to choose the target.

Learning outcomes

After completing this lesson, you will be able to:

  • Recognise common automation patterns.
  • Choose the target with the least custom code.
  • Design automated responses that are safe.
  • Schedule actions with EventBridge Scheduler.

Common patterns

Most operational automation follows a small number of patterns. Each starts from an event that an AWS service publishes on the default event bus, such as a state change, a finding or a scheduled health event, and ends with a target that notifies people or changes resources. Recognising the pattern in a scenario usually identifies the event source and the most suitable target. The following table lists the common patterns with the usual target.

Trigger eventAutomationTarget
EC2 Instance State-change (stopped)Restart or notifySystems Manager Automation or SNS
AWS API Call via CloudTrail (RunInstances, CreateBucket)Tag, validate or remediate new resourcesLambda
Config Rules Compliance ChangeFix non-compliant resourceSystems Manager Automation
AWS Health Event (scheduled change)Plan maintenance, stop/startSNS, Automation
GuardDuty Finding (high severity)Isolate instance, notifyStep Functions or Automation
Auto Scaling lifecycle actionConfigure or drain an instanceLambda or Automation
ECS Task State Change (STOPPED with error)Record and alertCloudWatch Logs, SNS
Schedule (EventBridge Scheduler)Stop dev instances nightly, run reportsAutomation, Lambda, universal targets

Choosing the target

Prefer the target that requires the least custom code. Systems Manager Automation runbooks suit AWS-centric procedures with audit trails and approvals. Lambda suits short custom logic under 15 minutes. Step Functions suits long-running, multi-step or branching workflows with waits, retries and human approval. SNS and SQS suit notification and buffering. EventBridge Scheduler with universal targets can call almost any AWS API directly, such as ec2:StopInstances, with no function at all.

Sort into groups

Which target?

Exam skills 3.2.2 · 1.2.2

Choose the EventBridge target for each automated response.

Log in to try this activity Interactive activities are free with an account.

Designing safe automated responses

Automation that acts on production resources must be designed so that it cannot cause more harm than the event it responds to. The event pattern should be as specific as possible, matching the exact source, detail type and resource attributes, so that the rule does not fire for unrelated events. Actions should be idempotent, producing the same result if an event is delivered twice, because EventBridge delivers at least once.

A common failure is an automation loop: a rule reacts to a change, its target makes another change of the same kind, and that change triggers the rule again. Loops are avoided by excluding the automation's own role in the event pattern, by matching only the specific change that needs fixing, or by checking the current state before acting. Destructive or high-impact actions, such as terminating instances or revoking access, can include an approval step in an Automation runbook or a Step Functions workflow, and every automated action should be logged and notified so that operators know what changed.

The following diagram shows a loop and the two design rules that prevent it.

An automation loop and how to prevent it. A rule reacts to a change, its target makes another change of the same kind, and that change matches the rule again. Specific patterns that exclude the automation's own role or a marker tag, and idempotent actions, break the loop, because EventBridge delivers at least once.
The events are illustrative. Alarms on the rule's invocation count reveal a loop quickly.
Troubleshooting scenario

Runaway automation

Exam skills 3.2.2 · 1.2.2

Fix automated responses that misbehave.

Log in to try this activity Interactive activities are free with an account.
Worked example

Stopping development instances at night

A company wants all EC2 instances tagged Env=dev stopped at 20:00 and started at 07:00 on weekdays in the London time zone. The operator creates two EventBridge Scheduler schedules with cron expressions and the Europe/London time zone, each targeting the Systems Manager Automation runbooks AWS-StopEC2Instance and AWS-StartEC2Instance with the tag as the target and a rate control of 20%. An alternative, the AWS Instance Scheduler solution, offers more scheduling features but requires deploying and maintaining a solution stack.

Check yourself

Which target suits a long, multi-step workflow with retries and waits?

Show answer

AWS Step Functions. Lambda suits short custom logic, and Automation suits auditable AWS procedures.

Exam Tips

Remember for the exam

  • Match the trigger event to the simplest capable target.
  • Use Automation for auditable AWS procedures, Lambda for short custom logic, Step Functions for long workflows.
  • EventBridge Scheduler universal targets call AWS APIs without code.
  • Config compliance changes and Health events are common automation triggers.