An online retail company runs a web application on a fleet of Amazon EC2 instances managed by an Auto Scaling group. The DevOps team wants to automate the configuration management of these instances by applying an Ansible playbook stored in a secured Amazon S3 bucket. The solution must ensure that the configuration is applied automatically to all newly launched instances, and that any subsequent manual configuration changes on the instances are detected and corrected every 24 hours. Which of the following approaches represents the most operationally efficient way to meet these requirements?
- Create an AWS Systems Manager State Manager association. Specify the document as AWS-ApplyAnsiblePlaybooks and configure the source parameter to point to the Amazon S3 bucket. Target the EC2 instances using the Auto Scaling group's resource tags, and set the association schedule to run every 24 hours.Answer
- BConfigure the Auto Scaling group to launch instances with a User Data script that downloads and executes the Ansible playbook. Create an Amazon EventBridge rule that runs on a 24-hour schedule to invoke an AWS Lambda function, which runs a remote SSH command on all active EC2 instances to re-apply the playbook.
- CUse AWS CloudFormation StackSets to deploy the Auto Scaling group. Enable CloudFormation drift detection with an automatic remediation rule that downloads and runs the Ansible playbook from the Amazon S3 bucket whenever OS-level configuration drift is detected.
- DConfigure an AWS CodePipeline pipeline with an AWS CodeDeploy deployment group targeting the Auto Scaling group. Write a CodeDeploy Hook script to run the Ansible playbook, and configure a cron job within the instance operating system to trigger a new pipeline deployment every 24 hours.
Answer
Create an AWS Systems Manager State Manager association targeting the instances using the Auto Scaling group's tags, specifying the AWS-ApplyAnsiblePlaybooks document with the Amazon S3 source path, and setting a 24-hour execution schedule.
The correct approach utilizes AWS Systems Manager State Manager with the AWS-ApplyAnsiblePlaybooks document. State Manager is designed to enforce configuration state on EC2 instances. It automatically applies to new instances when they register and match the targeted tags, and runs on a recurring schedule to correct any configuration changes made manually.
Step-by-Step Solution
Key Concept
AWS Systems Manager State Manager provides a native, scalable solution for defining and enforcing resource state configurations, automatically applying them to new instances and remediating configuration drift on a schedule.