OpsWorks is an implementation of the Chef configuration management and deployment platform. OpsWorks moves away from the low-level configurability of CloudFormation but not as far as Elastic Beanstalk. OpsWorks lets you create a stack of resources with layers and manage resources as a unit.
- Flexible way to create and manage resources for our applications.
- Create a stack of resources and manage resources in layers.
- Use OpsWorks to automate, monitor, and maintain deployments.
- OpsWorks provides abstraction from the underlying infrastructure, while still giving plenty of control, with more customization than Elastic Beanstalk.
- It uses Chef, an open-source tool that automates infrastructure by turning it into code.
OpsWorks Components
Stacks
- A unit of managed infrastructure
- Can use stacks per application or per platform
- Could use stacks for development, staging, or production environments
- Represent a set of resources we want to manage as a group
Layers
- Comparable to application tiers within a stack
- e.g., database layer, application layer, proxy layer
- Recipes are generally associated with layers and configure what to install on instances in that layer
- Used to represent and configure components of a stack
- We can use built-in layers and customize those or create completely custom layers
- Recipes are added to layers
Instances
- Instances are EC2 instances associated with a layer
- Configured as 24/7, load based, or time based
- Must be associated with at least one layer
Apps
- Apps are deployed to layers from a source code repo or S3
- Actual deployment happens using recipes on a layer.
- Other recipes are run when deployments happen, potentially to reconfigure other instances
- Apps are deployed to the application layer through a source code repository like Git, Subversion, or S3
- We can deploy an app against a layer and have OpsWorks execute recipes to prepare instances for the application
Recipes
- Setup: Executed on an instance when first provisioned
- Configure: Executed on all instances when instances are added or removed
- Deploy and Undeploy: Executed when apps are added or removed
- Shutdown: Executed when an instance is shut down but before it’s stopped
Recipes
- Created using the Ruby language and based on the Chef deployment software
- Custom recipes can customize different layers in an application
- Recipes are run at certain predefined events within a stack
- Setup: Occurs on a new instance after first boot
- Configure: Occurs on all stack instances when they enter or leave the inline state
- Deploy: Occurs when we deploy an app
- Undeploy: Happens when we delete an app from a set of application instances
- Shutdown: Happens when we shut down an instance (but before it is actually stopped)