Applying Configuration Changes in Response to Events
Many operational changes are reactions: a new instance needs configuration, an IP range changed, a parameter was updated, an alarm indicates a configuration is wrong. Responding manually is slow and inconsistent. This lesson explains the mechanisms for applying configuration changes to systems and modifying infrastructure automatically when events occur, and the controls that keep such automation safe.
Learning outcomes
After completing this lesson, you will be able to:
- Describe event-driven mechanisms for applying configuration changes to instances, containers and applications.
- Explain how infrastructure configurations are modified in response to events, including through IaC pipelines.
- Explain how change windows, approvals and rate controls make automated changes safe.
- Choose an appropriate response mechanism for a given event and change.
Mechanisms for Applying Changes to Systems
The tools introduced in earlier modules each apply configuration in response to events in a different way. The most important are described below.
- State Manager associations apply desired configuration automatically to new nodes that match their targets, so a scale-out event results in a configured instance without any explicit trigger. Changing the association, or its parameter in Parameter Store, reapplies configuration across the fleet.
- Run Command and Automation targets in EventBridge rules run a document or runbook when a specific event occurs, such as installing an agent when an instance enters the running state or rotating logs when a disk usage alarm fires.
- Auto Scaling lifecycle hooks run configuration at launch or clean-up at termination, as described in the scaling module.
- AWS AppConfig deploys application configuration changes gradually and rolls them back when alarms fire, so a configuration change is itself an event-driven, monitored process.
- Parameter Store change events trigger redeployments or cache refreshes, for example an EventBridge rule on a parameter change that starts an ECS service deployment so tasks pick up the new value.
- CloudWatch alarm actions change capacity (Auto Scaling) or instance state (reboot, recover) directly.
Modifying Infrastructure in Response to Events
Infrastructure changes triggered by events should normally go through the same IaC path as planned changes, so that templates remain the source of truth. Two approaches are common.
Event-triggered pipelines
An EventBridge rule starts a CodePipeline pipeline or a CloudFormation stack update when an event occurs, such as a new golden AMI published by Image Builder, a new base image in ECR or a change to a parameter that the template reads. The pipeline applies the change with the usual tests, change sets and approvals. This keeps every infrastructure change reviewed and recorded.
Direct, targeted changes
Some changes are small, frequent and well defined, and running a full pipeline for each would be excessive. A Lambda function or Automation runbook makes the change directly, for example updating a managed prefix list or security group when a partner's IP ranges change, adding a newly created account's VPC to a Transit Gateway route table, or adjusting provisioned capacity before a scheduled event. Direct changes to resources managed by CloudFormation create drift, so they should target resources designed to be changed this way, such as prefix lists referenced by templates, or update the template's parameter and the stack.
A classic example is keeping security groups aligned with AWS IP ranges. AWS publishes changes to its IP address ranges through an SNS topic (AmazonIpSpaceChanged), and a subscribed Lambda function can update a security group or prefix list. Where AWS provides managed prefix lists, such as for CloudFront origin-facing addresses, referencing the managed list removes the need for automation altogether, which is the preferable design.
Making Automated Changes Safe
Automation that changes production must be controlled as carefully as human changes, and in one respect more carefully: a person who makes a mistake usually affects one system, while an automated change with a fault can be applied to every instance or account within minutes. The same speed that makes automation valuable also amplifies its errors. The controls for automated changes therefore aim to limit when a change runs, how far it spreads before its effect is known, what it is allowed to touch and how quickly it can be reversed.
Change windows keep automated changes out of freezes and peak periods. Approvals insert a human decision before high-risk steps. Rate control, through concurrency and error thresholds, applies a change to a few targets first and stops it automatically if too many fail. Least privilege limits the automation's role to the actions it needs, so a fault cannot reach unrelated resources. Monitoring with rollback reverses a change that degrades the system, and auditing records every change so that incidents can be traced to their cause. The controls below are used together.
| Control | Mechanism | Protects against |
|---|---|---|
| Change windows | Systems Manager Change Calendar; maintenance windows; CodePipeline deployment window conditions | Changes during freezes or peak periods |
| Approvals | aws:approve in Automation; manual approval in CodePipeline; Step Functions callbacks | Unreviewed high-risk changes |
| Rate control | Concurrency and error thresholds in Run Command, Automation and State Manager; StackSets operation preferences | A faulty change spreading across the fleet |
| Least privilege | Dedicated AutomationAssumeRole and function roles scoped to specific actions and tags | Automation doing more than intended |
| Monitoring and rollback | Alarms on AppConfig, CodeDeploy, ECS and CloudFormation rollback triggers | Changes that degrade the system |
| Audit | CloudTrail, Automation execution history, Config timelines | Untraceable changes |
Choosing a mechanism
In scenarios that ask for an automated response with the least operational overhead, prefer built-in mechanisms (State Manager for new nodes, Config remediation, AppConfig rollback, alarm actions) over custom Lambda code, and prefer EventBridge to polling.
Make automation safe
Reacting to Configuration Events
An operations team lists four situations that currently require manual work. The table shows the automated response chosen for each.
| Event | Automated response |
|---|---|
| New instances launched by any team must have the vulnerability agent and log configuration | State Manager associations targeting all managed nodes by tag apply both automatically |
| A database connection string in Parameter Store changes | An EventBridge rule on the parameter change starts a new ECS deployment so tasks reload configuration |
| Image Builder publishes a new hardened AMI | An EventBridge rule starts a pipeline that updates the launch template parameter and performs an instance refresh with checkpoints |
| A partner changes its IP addresses, notified by webhook | API Gateway and a Lambda function update the customer managed prefix list referenced by the security groups |
Why is it better for an event to start a pipeline that updates a CloudFormation stack than for a Lambda function to modify the stack's resources directly?
Show answer
Direct modification causes drift between the template and the resources, bypasses tests, change sets and approvals, and may be reverted by the next stack update. A pipeline keeps the template as the source of truth and records the change.
Exam Tips
Remember for the exam
- State Manager configures new nodes automatically; EventBridge rules can run Run Command, Automation runbooks, Lambda or pipelines for specific events.
- Route infrastructure changes through IaC pipelines where possible; make direct changes only to resources designed for it, such as prefix lists.
- Prefer AWS managed prefix lists over automation that tracks AWS IP ranges.
- Control automated changes with Change Calendar, approvals, rate controls, least-privilege roles, alarms and audit trails.