Menu
AWS for DevOps
Getting Started Guide

Step 6: Set Up for AWS OpsWorks

In this step, you will create AWS resources that AWS OpsWorks will use to deploy the source code to the deployment target (an Amazon EC2 instance running Amazon Linux).

If you want to deploy with AWS CodeDeploy, go to Step 4: AWS CodeDeploy Setup.

If you want to deploy with AWS Elastic Beanstalk, go to Step 5: Elastic Beanstalk Setup.

To log in to and explore the deployment target, you will need an Amazon EC2 key pair. You can use the key pair you created or identified in Step 2.2: Create a Key Pair.

The following procedure uses an AWS CloudFormation template to create an AWS OpsWorks stack, layer, app, service role, and an IAM instance profile and to launch an Amazon Linux instance. (To view the contents of the AWS CloudFormation template, see OpsWorksSetup.template.) To learn how to create these resources in other ways, such as with the AWS Management Console or the AWS Command Line Interface (AWS CLI), see the following topics in the AWS OpsWorks User Guide:

To create the AWS OpsWorks resources

  1. Use the AWS CloudFormation console to create a stack in the US East (N. Virginia) region based on the following Amazon S3 template URL: https://s3.amazonaws.com/aws-for-devops/cfn-templates/OpsWorksSetup.template

    On the Specify Details page, the settings in the Parameters area are used to:

    • Create an AWS OpsWorks stack that launches, by default, Amazon EC2 instances running Amazon Linux and Chef 11.10.

    • In the AWS OpsWorks stack, create an AWS OpsWorks layer that is optimized for PHP apps.

    • In the AWS OpsWorks stack, create an AWS OpsWorks app that is based on a simple PHP solution.

    • Create a default AWS OpsWorks service role that enables AWS OpsWorks to interact with dependent AWS services on the user's behalf.

    • In the AWS OpsWorks layer, launch an Amazon EC2 instance running Amazon Linux that is compatible with AWS OpsWorks and Chef 11.10. This instance allows users to log in to it by using the SSH protocol and to access it by using the HTTP protocol. The AWS OpsWorks default IAM instance profile is attached to the instance. This IAM instance profile enables the instance to take actions related to AWS OpsWorks and its dependent AWS services for AWS resources across the AWS account.

    To accept these default settings, type your Amazon EC2 key pair name (for example, the one you created in Step 2.2: Create a Key Pair) into KeyPair, and then go to step 2 of this procedure.

    Alternatively, you may want to experiment with these default settings by running this template multiple times to create AWS OpsWorks, IAM, and Amazon EC2 resources for this walkthrough. For example, later on you may want to create more AWS OpsWorks stacks, layers, or apps. Or you may want to launch more Amazon EC2 instances that are compatible with AWS OpsWorks.

    The following table shows which settings to choose in the Parameters area.

    I want to create a new AWS OpsWorks stack that, by default, launches Amazon EC2 instances running Amazon Linux and Chef 11.10.

    Leave Stack set to the default value of New. For StackName, type the name of the new AWS OpsWorks stack.

    The new stack must have an AWS OpsWorks service role. To create a new default AWS OpsWorks service role, leave ServiceRole set to the default value of New.

    Note

    Set ServiceRole to Existing if you already have a service role you want to use. Type the Amazon Resource Name (ARN) of the service role in ServiceRoleARN. The service role must be compatible with AWS OpsWorks. For more information, see Allowing AWS OpsWorks to Act on Your Behalf in the AWS OpsWorks User Guide.

    The new stack must also have a default IAM instance profile to attach to all associated Amazon EC2 instances. To create a default IAM instance profile, leave InstanceProfile set to the default value of New.

    Note

    Set InstanceProfile to Existing if you already have an IAM instance profile you want to use. Type the ARN of the IAM instance profile in InstanceProfileARN. The IAM instance profile must be compatible with AWS OpsWorks. For more information, see Specifying Permissions for Apps Running on Amazon EC2 Instances in the AWS OpsWorks User Guide.

    I want to create a new AWS OpsWorks layer that is optimized for PHP apps.

    Leave Layer set to the default value of New.

    Optionally, you can associate an existing Amazon EC2 security group with the layer. This security group will be associated with all Amazon EC2 instances launched into the layer. Set CustomSecurityGroup to Yes, and type the security group ID in CustomSecurityGroupID.

    I want to launch a new Amazon EC2 instance running Amazon Linux that is compatible with AWS OpsWorks and Chef 11.10.

    Leave Instance set to the default value of Yes. Enter the instance type into Type. Type your Amazon EC2 key pair name into KeyPair.

    The instance must have an associated AWS OpsWorks stack. Set Stack to New or Existing. If you set Stack to New, type the name of the new AWS OpsWorks stack into StackName. If you set Stack to Existing, type the AWS OpsWorks ID of the stack into StackID. Be sure to set ServiceRole, ServiceRoleARN, InstanceProfile, and InstanceProfileARN as needed.

    The instance must also have an AWS OpsWorks layer associated with the new or existing AWS OpsWorks stack. Set Layer to New or Existing. If you set Layer to New, type the name of the new AWS OpsWorks layer into LayerName. If you set Layer to Existing, type the AWS OpsWorks ID of the existing AWS OpsWorks layer into LayerID.

    I want to create a new AWS OpsWorks app that is based on a simple PHP solution.

    Leave App set to the default value of Yes. For AppName, type the name of the new AWS OpsWorks app.

    The AWS OpsWorks app must have an associated AWS OpsWorks stack. Set Stack to New or Existing. If you set Stack to New, type the name of the new AWS OpsWorks stack into StackName. If you set Stack to Existing, type the AWS OpsWorks ID of the existing AWS OpsWorks stack into StackID. Be sure to set ServiceRole, ServiceRoleARN, InstanceProfile, and InstanceProfileARN as needed.

  2. When CREATE_COMPLETE is displayed for Status for the stack, choose the Resources tab. Make a note of the following Physical ID values. You will need them for Step 7.3: Create and Run the Pipeline for AWS OpsWorks.

    • OpsWorksApp

    • OpsWorksLayer

    • OpsWorksStack

  3. Continue on to explore the resources created by the stack. Otherwise, go to Step 7.3: Create and Run the Pipeline for AWS OpsWorks.

To explore the AWS OpsWorks resources created by the AWS CloudFormation stack

  1. Open the AWS OpsWorks console at https://console.aws.amazon.com/opsworks/.

  2. On the OpsWorks Dashboard page, choose the AWS OpsWorks stack.

  3. On the AWS OpsWorks stack's overview page, choose Stack Settings.

  4. Choose Layers.

  5. On the Layers page, for the layer, choose Settings.

  6. Choose Apps.

  7. On the Apps page, choose the AWS OpsWorks app.

  8. Choose Instances.

  9. On the Instances page, choose the Hostname link to view the settings for the instance. You'll find more information by choosing the EC2 Instance ID link on the Details page.

  10. To log in to the instance, follow the instructions in Connect to Your Linux Instance in the Amazon EC2 User Guide for Linux Instances.

To explore the IAM resources created by the AWS CloudFormation stack

  1. In the AWS CloudFormation console, choose the Resources tab.

  2. To explore the IAM instance profile, for OpsWorksInstanceProfileRole, choose the Physical ID link.

  3. To explore the service role, for OpsWorksServiceRole, choose the Physical ID link.

  4. Go to Step 7.3: Create and Run the Pipeline for AWS OpsWorks.