Maintaining Desired State with State Manager
Configuration drifts over time: services are stopped, files are edited and agents are removed. Desired-state configuration continuously reapplies the intended configuration. This lesson explains State Manager associations, how they apply Systems Manager documents, Ansible playbooks, Chef recipes and PowerShell DSC configurations, how Distributor installs software, and the status of AWS OpsWorks.
Learning outcomes
After completing this lesson, you will be able to:
- Explain how State Manager associations apply and reapply configuration on a schedule.
- Describe how State Manager runs Ansible playbooks, Chef recipes and PowerShell DSC configurations.
- Explain how Distributor packages and the AWS-ConfigureAWSPackage document install software across fleets.
- Describe the end-of-life status of AWS OpsWorks and the recommended alternatives.
Desired-State Configuration
Imperative scripts describe steps; desired-state configuration describes the end state and converges the system to it whenever it differs. If an administrator stops a required service, the next run starts it again; if the configuration is already correct, nothing changes. This idempotent, repeated application keeps a fleet compliant without manual checking, and it also brings newly launched nodes to the correct configuration automatically.
State Manager Associations
An association binds a document, its parameters and a set of targets to a schedule. State Manager runs the association when it is created, when new nodes matching the targets appear, and then on its schedule, such as every 30 minutes or on a cron expression; the option ApplyOnlyAtCronInterval skips the immediate run. Targets are selected by tags, resource groups or all managed nodes, so new instances with the right tags are configured within minutes of launch.
Associations support the same concurrency and error-threshold rate controls as Run Command, and they are versioned, so a change can be rolled back to a previous association version. Each association has a compliance severity; the result of each run is recorded as association compliance in Systems Manager Compliance, which shows which nodes are not in the desired state. Associations can also target AWS resources with Automation runbooks, for example to enforce settings on S3 buckets.
Common AWS documents used in associations are listed below.
| Document | Purpose |
|---|---|
| AWS-GatherSoftwareInventory | Collect inventory metadata (see the Inventory lesson) |
| AWS-UpdateSSMAgent | Keep the SSM Agent current |
| AWS-ConfigureAWSPackage | Install or uninstall Distributor packages, such as the CloudWatch agent |
| AmazonCloudWatch-ManageAgent | Configure and start the CloudWatch agent from a Parameter Store configuration |
| AWS-RunPatchBaseline | Scan for or install patches |
| AWS-ApplyAnsiblePlaybooks | Run Ansible playbooks from S3 or GitHub |
| AWS-ApplyChefRecipes | Run Chef recipes from S3 or GitHub |
| AWS-ApplyDSCMofs | Apply PowerShell Desired State Configuration MOF files on Windows |
Using Existing Configuration Management Code
Many organisations already have configuration code written for Ansible, Chef or PowerShell DSC. State Manager can run that code without dedicated configuration servers. AWS-ApplyAnsiblePlaybooks downloads playbooks from S3 or GitHub and runs them locally on each node in check or apply mode. AWS-ApplyChefRecipes runs Chef cookbooks in local mode, removing the need for a Chef server. AWS-ApplyDSCMofs applies compiled DSC MOF files, reporting compliance per resource. In each case, State Manager provides scheduling, targeting, rate control, logging and compliance reporting, and the configuration code remains in version control.
Desired-state documents
Distributor
Distributor packages software for installation by Systems Manager. A package contains installable files for each supported platform and install, uninstall and update scripts, and it is versioned. AWS publishes packages for its own agents, such as AmazonCloudWatchAgent, AWSCodeDeployAgent and the Amazon Inspector agent, and organisations can create private packages for their own software. Packages are installed once with Run Command or kept installed with a State Manager association using AWS-ConfigureAWSPackage, which is the standard way to deploy agents across a fleet.
AWS OpsWorks Status
AWS OpsWorks provided managed Chef and Puppet servers (OpsWorks for Chef Automate and OpsWorks for Puppet Enterprise) and OpsWorks Stacks, which modelled applications as stacks and layers configured with Chef recipes run at lifecycle events (setup, configure, deploy, undeploy and shutdown). All OpsWorks services reached end of life in 2024 and are no longer available. The exam guide still names OpsWorks as an example of a configuration management service, so recognise it in scenarios, but the current answers for desired-state configuration are State Manager associations (including running existing Chef recipes or Ansible playbooks) and, for application configuration, AWS AppConfig. AWS published migration guidance from OpsWorks Stacks to Systems Manager Application Manager and State Manager.
OpsWorks in exam options
If an exam option proposes OpsWorks for a new deployment, treat it as outdated unless no current alternative is offered. Prefer State Manager associations for configuration enforcement.
Keeping an Agent and a Configuration in Place
Security requires every Linux instance to run the CloudWatch agent with a standard configuration and to have a hardened SSH daemon configuration managed by an existing Ansible playbook. Instances are launched by many teams, and some administrators have removed the agent to save memory.
-
Agent installation
An association runs AWS-ConfigureAWSPackage with the AmazonCloudWatchAgent package on all Linux managed nodes every day.
-
Agent configuration
A second association runs AmazonCloudWatch-ManageAgent with a configuration stored in Parameter Store.
-
Hardening
A third association runs AWS-ApplyAnsiblePlaybooks with the playbook from the security team's repository every 30 minutes with a compliance severity of HIGH.
-
Visibility
Systems Manager Compliance and AWS Config show non-compliant nodes, and an EventBridge rule on association compliance changes notifies the security team.
A company runs Chef recipes on OpsWorks Stacks and must move to a supported service while reusing the recipes. What should it use?
Show answer
Systems Manager State Manager with the AWS-ApplyChefRecipes document, which runs the recipes locally on a schedule without a Chef server. OpsWorks has reached end of life.
Exam Tips
Remember for the exam
- State Manager associations bind a document, parameters, targets and a schedule; they run on new matching nodes automatically and record association compliance.
- Use AWS-ApplyAnsiblePlaybooks, AWS-ApplyChefRecipes and AWS-ApplyDSCMofs to run existing configuration code without configuration servers.
- Distributor packages plus AWS-ConfigureAWSPackage install and keep agents such as the CloudWatch agent on fleets.
- AWS OpsWorks reached end of life in 2024; State Manager is the current desired-state answer.