Step 14: Update the Cookbook to Use
Iteration

Update your cookbook by adding a recipe that uses iteration, a
technique that repeats recipe code multiple times. This recipe displays messages in
the log
for a data bag item that contains multiple contents.

To update the cookbook on the instance and to run the new recipe

On your local workstation, in the recipes subdirectory in the
opsworks_cookbook_demo directory, create a file named
iteration_demo.rb that contains the following code:

This recipe displays messages in the log for a data bag item that contains multiple
contents. The data bag item is in the aws_opsworks_stack data bag. The
data bag item has content named custom_cookbooks_source. Inside of this
content are six contents named type, url,
username, password, ssh_key,
and revision; their values are also displayed.

In the next step, you
will update the cookbook to run recipe code only if certain conditions are met.

Javascript is disabled or is unavailable in your browser.

To use the AWS Documentation, Javascript must be enabled. Please refer to your browser's
Help pages for instructions.