AWS OpsWorks Stacks Quick Reference

AWS OpsWorks Stacks is services that sits in between the fully customizable CloudFormation and the Platform as a Service convenience of Elastic Beanstalk. At its core it helps manage a collection of AWS resources (EC2\RDS) that support an application or setup of application (microservices). It can also be thought of as a wrapper around Chef, a ruby based infrastructure automation and configuration tool.

AWS OpsWorks Stacks Components

Stacks:

Are the core grouping for AWS OpsWorks stacks and include every resource need for the application (Instances, Databases, etc). Defaults like operation systems type and version or deployed regions are configured at the Stack level.

Layers:

Stacks are made of one or more layers. Layers are one or more EC2 instances serve a purpose like web, database or worker. A colleciton service layers are included in each stack. The service layers include Relational Database, Elastic Container Service and Elastic Load Balancing.

Life Cycle Events:

A Layers instances are managed through life cycle events and Chef confguration management recipes triggered on these events. Life cycle events include:

1. Setup:
The setup event runs recipes to install or setup software based on its layer upon instance boot or when the setup command has been excuded on the instance. This take the instance offline and will not server an application during setup.

2. Configure:
The configure event runs all instance of the stack when A) an instance comes online, B) an Elastic IP is assigned or unassigned to an instance and C) An Elastic Load Balancer is added or removed from a layer. The event allows for updating configurations for each layer in the stack. For example, adding an instance to a load balancer.

3. Deploy:
This event is used to deploy code to a running instance. The setup life cycle event will the deploy event.

5. Undeploy
This event is for clean up and runs Chef recipes on instances when an app is deleted or the undeploy command is run.

7. Shutdown
Event occurs between shutdown and termination. Its intend to allow for shutdown of supporting services (e.g. Httpd) and other clean up task. Reboots will not trigger a shutdown event.

Instances

In OpsWorks an instance reference to a single compute resource which can be an EC2 instance or onpremise server. An instances can be apart of multiple layers and gets its configuration and setup from layer recipes. The OpsWorks agent is installed on each instance. The agent monitors the instance and runs recipes corresponding to life cycle events. There are 3 types of instance usagage patterns:

24/7: running all the time until stopped
Time-based: running be a preconfigured schedule (i.e. 9-5 M/F)
Load-based: scaling up or down the number of running instances based on CPU load.

If an instance is unresponsive OpsWorks will attempt to Auto-heal the instance by stoping and restarting the instance.

Apps:

Apps are stored in version control git or S3 and deployed on instance startup or when the deploy command is used. The deploy command can update a subset or apps for testing new features or apps running on all instances. Five versions of an app are maintained add OpsWorks allow for rolling back 4 version.

Additional Resources:

OpsWorks allow for registering additional resources to a stack, layer or instance such as Elastic Load Balancers or Elastic IPs.

Monitoring & Loging:

  • AWS OpsWorks includes a monitoring page with CloudWatch metrics.
  • AWS CloudTrail logs provides an audit log of all AWS API calls in OpsWorks.
  • An event log shows all events in a stack.
  • Chef logs show details of recipes ran based on life cycle events for each instances.

Joe Bennett

Read more posts by this author.