Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Step 4: Assign the Recipes to LifeCycle Events

Focus mode
Step 4: Assign the Recipes to LifeCycle Events - AWS OpsWorks
Important

The AWS OpsWorks Stacks service reached end of life on May 26, 2024 and has been disabled for both new and existing customers. We strongly recommend customers migrate their workloads to other solutions as soon as possible. If you have questions about migration, reach out to the AWS Support Team on AWS re:Post or through AWS Premium Support.

You can run custom recipes manually, but the best approach is usually to have AWS OpsWorks Stacks run them automatically. Every layer has a set of built-in recipes assigned to each of five lifecycle events—Setup, Configure, Deploy, Undeploy, and Shutdown—. Each time an event occurs on an instance, AWS OpsWorks Stacks runs the associated recipes for each of the instance's layers, which handle the required tasks. For example, when an instance finishes booting, AWS OpsWorks Stacks triggers a Setup event to run the Setup recipes, which typically handle tasks such as installing and configuring packages .

You can have AWS OpsWorks Stacks run custom recipes on a layer's instances by assigning each recipe to the appropriate lifecycle event. AWS OpsWorks Stacks will run any custom recipes after the layer's built-in recipes have finished. For this example, assign appsetup.rb to the PHP App Server layer's Deploy event and dbsetup.rb to the MySQL layer's Deploy event. AWS OpsWorks Stacks will then run the recipes on the associated layer's instances during startup, after the built-in Setup recipes have finished, and every time you deploy an app, after the built Deploy recipes have finished. For more information, see Automatically Running Recipes.

To assign custom recipes to the layer's Deploy event
  1. On the AWS OpsWorks Stacks Layers page, for the PHP App Server choose Recipes and then choose Edit.

  2. Under Custom Chef Recipes, add the recipe name to the deploy event and choose +. The name must be in the Chef cookbookname::recipename format, where recipename does not include the .rb extension. For this example, you enter photoapp::appsetup. Then choose Save to update the layer configuration.

    Custom Chef Recipes configuration with Repository URL and lifecycle events.
  3. On the Layers page, choose edit in the MySQL layer's Actions column.

  4. Add photoapp::dbsetup to the layer's Deploy event and save the new configuration.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.