Creating a Layer in AWS OpsWorks
Lab Steps
Introduction
In this lab step, you will create a layer in AWS OpsWorks that will represent and hold the instances to make up your PHP application servers.
Â
Instructions
1. Click Add a layer:
Â
2. Ensure the OpsWorks layer type is selected and then configure the following fields:
- Layer type: Select PHP App Server
This lab step does not cover attaching an Elastic Load Balancer (ELB) to the stack layer, but in a real-world setting, an ELB can evenly distribute traffic to the instances in this layer and improve the performance of your application.
To learn more about how an Elastic Load Balancer can improve your application, check out the AWS OpsWorks User Guide.
Â
3. Click Add Layer:Â
This will bring you to the Layers page.
Â
4. Click the Network setting under PHP App Server:
By default, instances launched in this layer will only receive a private IP address, which is not accessible from outside the VPC. For your application, you will need to configure this layer to automatically assign a public IP address to each instance launched in the layer.Â
Â
5. Click the toggle setting next to Public IP addresses to switch it to Yes:
Â
6. Click Save:
Â
7. At the top-right of the Layer PHP App Server page, click Instances:
Â
8. Click Add an instance:
Â
9. Ensure that the New tab is selected and click Advanced>> to expand all settings.
Â
10. Configure the following fields:
- Size: Select t2.micro
- Operating system: Ensure Amazon Linux 2017.09 is selected
Â
11. Click Add Instance:
Your php-app1 instance will be created but will notice it will have a Status of stopped. Adding an instance to a layer does not automatically start that instance.Â
Â
12. Click Start All Instances:Â
Starting your php-app1 instance can take up to 10 minutes.Â
During this time, the Status of your instance will be updated. Each status represents a different action AWS OpsWorks is performing on your behalf:
- requested:Â AWS OpsWorks has called the Amazon EC2 service to create the Amazon EC2 instance
- pending: AWS OpsWorks is waiting for the Amazon EC2 instance to start
- booting:Â The Amazon EC2 instance is booting
- running_setup:Â AWS OpsWorks has triggered the Setup event and is running the layer's Setup recipes, followed by its Deploy recipes.Â
- online:Â The instance is ready for use
Consider reading Using AWS OpsWorks Instances while you wait for your instance to boot up, or at a later time. EC2 instances are the "workers" of the AWS OpsWorks service, so it's beneficial to understand how to optimize this compute resource when working with AWS OpsWorks.
Â
13. Wait for the status of your instance to update to a Status of online:
Â
Summary
In this lab step, you created a layer in AWS OpsWorks that represents your PHP application servers.
Check that the OpsWork Layer has been created.