How to: set up a fully decoupled AWS Stack on a single EC2 instance - GovWizely/webservices GitHub Wiki
This guide follows the main setup guide, but at each step points out differences that need to be done in order to set up on just a single instance.
0. Prereqs
Create a new Stack:
Follow the steps given, but don't set up a VPC.
Security Groups
Rather than set up all described, just create one SG called "Webservices-SingleInstance, with SSH, HTTP and HTTPS open to the world.
Elasticsearch, Rails, Sidekiq Layers
In order to control the order in which recipes are applied, it's better to just create one layer and apply everything to it. Since one component of our stack is a Rails server, this single layer needs to be a Rails App Server layer. So for each layer described in the main documentation, follow the steps given but apply them to your one Rails App Server layer.
What follows are single-instance-specific instructions for each layer:
Elasticsearch Layer
- The config settings expected_nodes and minimum_master_nodes should be 1.
- ec2.groups should be Webservices-SingleInstance.
- Add
elasticsearch.allocated_memory: 1024m
to config. This will limit the amount of memory ES uses, allowing it to run stably on an m3.medium instance (which you'll want to use in order to keep costs down).
Load Balancer
Skip all this.
2. ElasticCache Instance
Skip all this.
3. Rails Layer and App
Rails App Server Layer
-
Remove:
- deploy.webservices.config.sidekiq
- deploy.webservices.config.elasticsearch
- deploy.webservices.symlink_before_migrate."config/elasticsearch.yml"
- deploy.webservices.symlink_before_migrate."config/initializers/sidekiq.rb"
from the Stack Custom JSON.
-
For the time-being, use the
calum/fully-decoupled-staging
branch. -
Add all recipes as listed except for
gw_webservices::adjust_elasticsearch_indices
. After your instance has successfully set up, addgw_webservices::adjust_elasticsearch_indices
to the deploy list and perform a deployment. This is necessary as the recipe requires Elasticsearch to be running, yet if it is in the initial setup list Elasticsearch (seems to) not have enough time to start, causing the recipe to fail.
4. Sidekiq Layer
- Add
redis-server
as an OS Package to your layer. - Add a
-c 5
option to the sidekiq command to reduce the concurrency (and therefore server load).