Lesson 2 of 3 Event-Driven Operations

Integrating AWS Health, CloudTrail and Service Events

Operational automation depends on knowing when something happens: AWS has scheduled maintenance on an instance, an API call changed a security group, a deployment failed or a task stopped. This lesson explains the main event sources the exam names, AWS Health, AWS CloudTrail and AWS service events, how each reaches EventBridge, and how they are combined with notification services to inform people and drive automation.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe AWS Health event types and the account and organisational views of AWS Health.
  • Explain how CloudTrail API calls are delivered to EventBridge and how to match them.
  • Identify common service events used in DevOps automation.
  • Describe notification options for people, including SNS, Amazon Q Developer in chat applications and AWS User Notifications.

AWS Health Events

AWS Health provides information about events that can affect AWS resources and accounts. Events have three categories: issues (service disruptions affecting the account), scheduled changes (planned activities such as EC2 instance retirement, scheduled maintenance of RDS instances or required updates) and account notifications (such as certificate expiry, end-of-support notices for runtimes or engine versions, and abuse reports). Events are account-specific, naming affected resources, or public, describing service status in a Region.

AWS Health publishes events to EventBridge with the source aws.health, which allows automation such as stopping and starting an EBS-backed instance scheduled for retirement to move it to new hardware, or creating a ticket for a scheduled RDS maintenance. With organisational view, enabled from the management account or a delegated administrator, Health events from all member accounts are visible centrally, and organisational events can be delivered to a central account through EventBridge. Programmatic access through the AWS Health API requires a Business Support+ or higher support plan; EventBridge delivery and the Health Dashboard in the console are available to all accounts.

{
  "source": ["aws.health"],
  "detail-type": ["AWS Health Event"],
  "detail": {
    "service": ["EC2"],
    "eventTypeCategory": ["scheduledChange"],
    "eventTypeCode": ["AWS_EC2_INSTANCE_RETIREMENT_SCHEDULED"]
  }
}

CloudTrail Events in EventBridge

Most AWS services do not publish an event for every change, but every API call is recorded by AWS CloudTrail. EventBridge receives CloudTrail management events as events with the detail-type AWS API Call via CloudTrail, so a rule can react to any API call, such as AuthorizeSecurityGroupIngress, PutBucketPolicy, CreateUser or StopLogging. The event's detail contains the event name, the caller identity, the source IP address, the request parameters and the response. Console sign-in events have the detail-type AWS Console Sign In via CloudTrail. Read-only API calls and data events require additional configuration, such as a trail that records them.

Because events are delivered for the Region in which the API call was made, calls to global services such as IAM are delivered in us-east-1; a rule for IAM changes must therefore be created in that Region. CloudTrail-based rules are the foundation of near-real-time security detection and automatic remediation, for example reverting an unauthorised security group change seconds after it happens.

{
  "source": ["aws.ec2"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["ec2.amazonaws.com"],
    "eventName": ["AuthorizeSecurityGroupIngress"],
    "requestParameters": {"ipPermissions": {"items": {"ipRanges": {"items": {"cidrIp": ["0.0.0.0/0"]}}}}}
  }
}

Global service events

A rule for IAM API calls created in eu-west-1 never fires, because IAM is a global service whose CloudTrail events are delivered in us-east-1. Create IAM rules in us-east-1 or forward events from there.

Service Events Used in DevOps Automation

Many services publish their own state-change events, which are more convenient than API call events. A CloudTrail event records that someone called an API, such as StartPipelineExecution, but it says nothing about what happened afterwards: whether the pipeline succeeded, which stage failed or whether a task stopped because it ran out of memory. Those outcomes are produced by the service itself, not by a caller, so they never appear as API calls. State-change events fill this gap. The service emits an event when a resource changes state, with fields such as the pipeline name, the failed stage or the stopped reason, so a rule can react to the outcome directly and the target receives the details it needs without calling back to the service.

As a rule of thumb, react to CloudTrail events when the question is who changed something, such as a security group modified outside the pipeline, and react to service events when the question is what happened to a process or resource, such as a failed deployment, an unsuccessful instance launch or a Spot interruption warning. Common examples are listed below.

SourceEventTypical automation
aws.codepipelinePipeline, stage and action execution state changeNotify on failures; start downstream pipelines
aws.codebuildBuild state change, build phase changeNotify on failed builds; collect reports
aws.codedeployDeployment and instance state changeNotify or open tickets on failed deployments
aws.ecsTask state change, service action, deployment state changeAlert on stopped tasks or failed deployments
aws.autoscalingInstance launch and terminate successful or unsuccessful, lifecycle actionsRun lifecycle hook automation; alert on launch failures
aws.ec2Instance state change, Spot interruption warning, rebalance recommendationClean-up, draining and replacement
aws.configConfiguration item change, compliance changeRemediation and notification
aws.guardduty and aws.securityhubFindingsSecurity response workflows
aws.s3Object created and deleted (when EventBridge is enabled for the bucket)File processing
aws.cloudwatchAlarm state changeRouting alarms to workflows
Sort into groups

Which event source?

Exam skills 5.1.1

Choose the event source that signals each situation.

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

Notifying People

Events that need human attention are delivered through notification services. Amazon SNS topics deliver to email, SMS, mobile push, HTTPS endpoints and chat. Amazon Q Developer in chat applications (formerly AWS Chatbot) delivers notifications from SNS and EventBridge to Slack and Microsoft Teams channels with formatted messages, and lets authorised users run read-only or approved commands from the chat. AWS User Notifications provides a central place to configure notifications for AWS events, including Health events and alarms, across accounts and Regions, delivered to the console notification centre, email, mobile apps and chat channels. Developer tools notification rules configure notifications for CodePipeline, CodeBuild and CodeDeploy events without writing EventBridge patterns.

Worked example

Handling Instance Retirements Automatically

An organisation receives frequent AWS Health notices that EC2 instances are scheduled for retirement. Engineers often miss them, and instances stop unexpectedly. Instances in Auto Scaling groups can be replaced, while standalone EBS-backed instances can be stopped and started outside business hours.

  1. Central view

    Enable AWS Health organisational view and forward aws.health events from all accounts to a central bus.

  2. Match

    A rule matches AWS_EC2_INSTANCE_RETIREMENT_SCHEDULED scheduled changes.

  3. Act

    A Step Functions workflow checks whether each affected instance is in an Auto Scaling group; if so, it sets the instance unhealthy so the group replaces it; otherwise it schedules a stop and start with EventBridge Scheduler in the next maintenance window using an SSM Automation runbook.

  4. Inform

    AWS User Notifications sends the owning team a summary.

Check yourself

A security team wants to be alerted within a minute whenever anyone calls StopLogging on a CloudTrail trail. What should it create?

Show answer

An EventBridge rule matching the AWS API Call via CloudTrail event with eventSource cloudtrail.amazonaws.com and eventName StopLogging, targeting an SNS topic or a remediation function, in each Region where trails are managed (or centrally through forwarded events).

Exam Tips

Remember for the exam

  • AWS Health events (issues, scheduled changes, account notifications) arrive in EventBridge with source aws.health; organisational view centralises them; the Health API needs Business Support+ or higher.
  • CloudTrail API calls reach EventBridge as AWS API Call via CloudTrail events; global service (IAM) events arrive in us-east-1.
  • Prefer service state-change events (CodePipeline, ECS, Auto Scaling, Config) where they exist.
  • Notify people with SNS, Amazon Q Developer in chat applications, AWS User Notifications or developer tools notification rules.