Step 2: Configure your stack and layer to use custom cookbooks - AWS OpsWorks

Step 2: Configure your stack and layer to use custom cookbooks

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.

Chef 12 stacks in AWS OpsWorks Stacks require your own or community-created cookbooks to build custom application layers. For this walkthrough, you can point to a repository that contains a set of Chef cookbooks and Chef recipes. These recipes install the Node.js package and its dependencies on your instance. You will use other Chef recipes to deploy the Node.js app that you will prepare in Step 4: Add your app to AWS OpsWorks Stacks. The Chef recipe that you specify in this step runs every time a new version of your application is deployed by CodePipeline.

  1. In the AWS OpsWorks Stacks console, open the stack that you created in Step 1: Create a stack, layer, and an instance in AWS OpsWorks Stacks. Choose Stack Settings, and then choose Edit.

  2. Set Use custom Chef cookbooks to Yes. This shows related custom cookbook settings.

  3. From the Repository type drop-down list, choose S3 Archive. To work with both CodePipeline and AWS OpsWorks, your cookbook source must be S3.

  4. For Repository URL, specify https://s3.amazonaws.com/opsworks-demo-assets/opsworks-linux-demo-cookbooks-nodejs.tar.gz. Your settings should resemble the following.

    Use custom Chef cookbooks settings.
  5. Choose Save.

  6. In the navigation pane, choose Layers.

  7. Choose Settings for the layer you created in Step 1: Create a stack, layer, and an instance in AWS OpsWorks Stacks.

  8. On the General Settings tab, be sure that the layer name is Node.js App Server, and the layer short name is app1. Choose Recipes.

  9. On the Recipes tab, specify nodejs_demo as the recipe you want to run during the Deploy lifecycle event. Choose Save.

  10. On the Security tab, from the Security groups drop-down list, choose the AWS-OpsWorks-Webapp security group.

  11. Choose Save.