DOP-C02 Practice Question 74: CFN Init CFN Hup Metadata Update
AWS Certified DevOps Engineer – Professional (DOP-C02) · Test 8 · question 4 of 10
A fleet of long-running EC2 instances is configured through AWS::CloudFormation::Init metadata on their launch template's underlying CloudFormation resource: a config set installs a package, writes an application configuration file, and starts a service. A DevOps engineer needs to push a change to that configuration file to every already-running instance by updating the stack, without replacing or rebooting any instance, and without SSH access or a custom Lambda function.
Which combination makes this work?
Show answer and explanation
Answer:
cfn-init only applies metadata at the moment it is invoked, typically once from UserData at launch; it does not watch for later changes on its own. cfn-hup is the companion daemon that polls the CloudFormation metadata for the resource on a schedule, and when it detects a change it runs the actions defined in its hook configuration, most commonly re-running cfn-init. With cfn-hup already running on every instance, updating the stack's AWS::CloudFormation::Init metadata is enough to have each running instance pick up and apply the new configuration file in place, with no replacement and no reboot.
Option A is wrong because UserData runs only when an instance boots (or, for some platforms, only on first boot); changing it in the template does not cause a running instance to re-execute it.
Option B achieves the update only by replacing every instance, which is the opposite of the "without replacing any instance" requirement, and rolling updates apply to Auto Scaling group instance refreshes, not metadata reapplication in place.
Option D describes a mechanism that does not exist; CloudFormation does not push metadata changes into an instance's IMDS, and there is no Immutable metadata attribute that triggers that behavior.
Reference: cfn-hup