Step 2.3: Add an Instance to the PHP App Server Layer - Chef 11
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
An AWS OpsWorks Stacks instance represents a particular Amazon EC2 instance:
-
The instance's configuration specifies some basics like the Amazon EC2operating system and size; it runs but doesn't do very much.
-
The instance's layer adds functionality to the instance by determining which packages are to be installed, whether the instance has an Elastic IP address, and so on.
AWS OpsWorks Stacks installs an agent on each instance that interacts with the service. To add a
layer's functionality to an instance, AWS OpsWorks Stacks directs the agent to run small applications
called Chef recipes
Note
If you are curious about how the recipes work, all of the AWS OpsWorks Stacks built-in recipes are
in a public GitHub repository: OpsWorks Cookbooks
To add a PHP application server to MyStack, add an instance to the PHP App Server layer that you created in the previous step.
To add an instance to the PHP App Server layer
-
Open Add an Instance
After you finish adding the layer, AWS OpsWorks Stacks displays the Layers page. Click Instances in the navigation pane and under PHP App Server, click Add an instance.
-
Configure the Instance
Each instance has a default host name that is generated for you by AWS OpsWorks Stacks. In this example, AWS OpsWorks Stacks simply adds a number to the layer's short name. You can configure each instance separately, including overriding some of the default settings that you specified when creating the stack, such as the Availability Zone or operating system. For this walkthrough, just accept the default settings and click Add Instance to add the instance to the layer. For more information, see Instances.
-
Start the Instance
So far, you have just specified the instance's configuration. You have to start an instance to create a running Amazon EC2 instance. AWS OpsWorks Stacks then uses the configuration settings to launch an Amazon EC2 instance in the specified Availability Zone. The details of how you start an instance depend on the instance's scaling type. In the previous step, you created an instance with the default scaling type, 24/7, which must be manually started and then runs until it is manually stopped. You can also create time-based and load-based scaling types, which AWS OpsWorks Stacks automatically starts and stops based on a schedule or the current load. For more information, see Managing load with time-based and load-based instances.
Go to php-app1 under PHP App Server and click start in the row's Actions column to start the instance.
-
Monitor the Instance's Status during Startup
It typically takes a few minutes to boot the Amazon EC2 instance and install the packages. As startup progresses, the instance's Status field displays the following series of values:
-
requested - AWS OpsWorks Stacks has called the Amazon EC2 service to create the Amazon EC2 instance.
-
pending - AWS OpsWorks Stacks is waiting for the Amazon EC2 instance to start.
-
booting - The Amazon EC2 instance is booting.
-
running_setup - The AWS OpsWorks Stacks agent is running the layer's Setup recipes, which handle tasks such as configuring and installing packages, and the Deploy recipes, which deploy any apps to the instance.
-
online - The instance is ready for use.
After php-app1 comes online, the Instances page should look like the following:
The page begins with a quick summary of all your stack's instances. Right now, it shows one online instance. In the php-app1 Actions column, notice that stop, which stops the instance, has replaced start and delete.
-