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 is used for compliance checking, not for managing configuration files. Systems Manager Resource Data Sync is used for synchronizing data from on-premises systems to AWS, not for managing configuration files on EC2 instances.
EC2 launch templates are used to define instance configurations, but placing configuration file content directly in the launch template is not an ideal approach. While cfn-init can configure instances, cfn-hup polling for updates is necessary but not fully addressed in this option.
Launch templates do not directly manage configuration file content. Systems Manager Resource Data Sync is used for syncing data across multiple locations, but it’s not necessary for managing EC2 instance configuration files.
Using CloudFormation init metadata with cfn-init to configure instances and cfn-hup to poll for configuration file updates is the best approach. This ensures that configuration changes are automatically applied to EC2 instances with minimal delay when the CloudFormation template is updated.