Which solution will accomplish this?
In the CloudFormation template, add an AWS Config rule. Place the configuration file content in the rule’s InputParameters property, and set the Scope property to the EC2 Auto Scaling group. Add an AWS Systems Manager Resource Data Sync resource to the template to poll for updates to the configuration.
In the CloudFormation template, add an EC2 launch template resource. Place the configuration file content in the launch template. Configure the cfn-init script to run when the instance is launched, and configure the cfn-hup script to poll for updates to the configuration.
In the CloudFormation template, add an EC2 launch template resource. Place the configuration file content in the launch template. Add an AWS Systems Manager Resource Data Sync resource to the template to poll for updates to the configuration.
In the CloudFormation template, add CloudFormation init metadata. Place the configuration file content in the metadata. Configure the cfn-init script to run when the instance is launched, and configure the cfn-hup script to poll for updates to the configuration.
Explanations:
AWS Config rules are used for compliance and resource monitoring, not for directly managing configuration files or distributing them to EC2 instances. AWS Systems Manager Resource Data Sync is used for aggregating configuration data, but it does not directly handle the distribution of configuration files to EC2 instances in the way described.
While EC2 launch templates and cfn-init can be used to set up instances, the solution doesn’t address the requirement to keep the configuration file updated on running instances with minimal delay. The cfn-hup tool would be the correct tool for polling updates, but this approach doesn’t fully meet the requirement of easily updating configuration files via source control.
The AWS Systems Manager Resource Data Sync is not designed for pushing configuration files directly to EC2 instances. EC2 launch templates are used for instance configuration but do not automatically handle updates to application files like configuration files when changes occur.
This option correctly uses CloudFormation init metadata, which can include configuration files that are distributed to EC2 instances on launch. The cfn-init script applies the initial configuration, and the cfn-hup script ensures that updates to the configuration file are reflected with minimal delay by polling for changes. This solution integrates well with source control and CloudFormation.