A company uses AWS OpsWorks to manage a stack of EC2 instances. The operations team needs to deploy a new configuration file to all instances in a layer. Which approach should the team use to automate this deployment?
OpsWorks Stacks is built on Chef, and adding a custom Chef recipe to the layer's cookbook (then associating it with a lifecycle event such as Configure or Deploy, or triggering it on demand) is the native, idempotent mechanism for pushing configuration file changes to every instance in that layer consistently and repeatably.
Why this answer
The correct answer is B: adding a Chef recipe to the layer's custom cookbooks that copies the configuration file to the instances. AWS OpsWorks Stacks is built on Chef, so configuration management tasks like distributing files to all instances in a layer are performed through recipes executed during lifecycle events (Setup, Configure, Deploy), making this the native and automated approach. Option A is not the OpsWorks-native mechanism and would bypass the stack's Chef-based lifecycle, requiring manual invocation or separate targeting.
Option C is incorrect because CloudFormation provisions infrastructure and does not manage in-instance configuration files for an existing OpsWorks stack. Option D is also wrong because CodeDeploy is a separate deployment service not integrated with OpsWorks Stacks' Chef recipe model.