Skip to content
Launches a load-balanced, auto-scaled, and auto-healing (NGINX) microservice in AWS
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
00_print_options.rb
01_create_vpc.rb
02_create_subnets.rb
03_create_igw.rb
04_create_rtbl_and_routes.rb
05_create_and_setup_SGs.rb
06_launch_nat_instances.rb
07_create_CLB_and_ALB.rb
08_launchconfig_and_asg.rb
99_vpc_complete_cleanup.rb
LICENSE
README.md
launch_and_cleanup.log
main.rb

README.md

Launches a load-balanced, auto-scaled, and auto-healing (NGINX) microservice in AWS.

2017-05-07
  • Mainly for demo purposes only

This code will create and build an AWS VPC from scratch. This also includes the required subnets, internet gateway, routing table, and routes, basically to demonstrate what goes on under the hood.

This will also create NAT instances (rather than using NAT gateways, because they are free for testing with t2.micro instances). This also allows the NGINX servers to be on private subnets only, without needing a public interface.

As examples, both a Classic LB (CLB) and an Application LB (ALB) are created, that both point to the backend NGINX servers.

An AWS launch configuration and auto scaling group are created and used.

The service can withstand the termination of a node and auto-heal.

If/when the code is requested to, it will completely nuke the created VPC and all that is associated with it. (-not- the default VPC).

Remaining action items:

  1. Run through the source and replace all occurrences of the `TODO' tag with proper code.
  2. Create classes out of the re-usable portions of code.
  3. Convert NAT instances back to NAT Gateways. NAT instances were free while testing.
  4. Finally, port this to Terraform, where it belongs. :)

aws-sdk gems may need to be installed:

$ gem install aws-sdk-resources aws-sdk-core aws-sdk

My versions:

$ gem list|grep aws
aws-sdk (2.9.15)
aws-sdk-core (2.9.15)
aws-sdk-resources (2.9.15)

Tested in us-west-2, and used creds from ~/.aws/credentials
Tested with 'default' and non-default profile names in the credentials file.

For usage, simply execute main.rb:
$ ruby main.rb

Author :: Cody Tubbs :: (codytubbs+ram@gmail.com)
https://github.com/codytubbs/ruby-aws-micoservice
https://github.com/codytubbs

You can’t perform that action at this time.