An image

Corporate Blogs

Ruby on Rails application in VPC environment – Setup walkthrough

E-Commerce Businesses Need a Mobile App


In the previous article we have seen “How to setup VPC environment using Ruby”. In this article we are going to setup a Ruby on Rails application in VPC environment.


When automated, the prerequisite parameters have to be passed on. In a manual or normal setup environment, these would not have been necessary since they would be given during the setting up of the instance inside the VPC environment. (We shall continue with the VPC environment that we set up in the previous article for the example to follow in the current one, and we shall set up the Ruby on Rails application in VPC environment that we setup then.)


• VPC Environment
• AWS Ami-Id
• Pem key name

AWS Ami-Id
Let’s assume we have an AWS EC2 image (of the client that we initialised in the previous article) which is already having Ruby, Ruby on Rails  and Database pre-installed, so that we can launch multiple instances using the same AMI.

Why do we need an ELB?
All the instances under private subnet will be protected from the outside word. We cannot make a direct communication outside the VPC environment. So using ELB we will make the HTTP/HTTPS requests from outside of the VPC environment.

Following are the steps involved:

1. Launching instances
2. Launching Elastic Load Balancer
3. Attach instances to ELB

Step : 1 – Launching instances
To launch an instance we need to pass the below required parameters:


Mentioned are the mandatory fields. There are several other optional fields which have not been mentioned here.

We need to interate the script for the number of API Servers that need to be launched.

Step : 2 – Launching Elastic Load Balancer
To create ELB we need to pass the ELB name, Array of listeners, Array of public subnet ids and Security group id. For every VPC, we need a new load balancer. We cannot attach instances that are created in another VPC.


Step : 3 – Attach instances to ELB
 After completion of steps 1 & 2, the newly created instances need to be attached to the ELB, so that the outside world can access the application that is deployed in the newly created instances.


Launching instances and ELB are completed. This successfully deploys a Ruby on Rails application in VPC environment. Now we can now run the Ruby on Rails application inside these instances and can access the application using ELB from the outside world. Thus, by following the default/necessary steps for a RoR app, we can successfully run the application within this environment.

Professional Life of an IT Consultant Interview with Valentin Crettaz
Written by
An enthusiastic Tech Lead with 7 plus years of experience in Web development arena. Owns legitimate experience in Ruby, Ruby On Rails, AngularJs, DevOps. Golang, Another add on, This young tech freak never miss a chance to get his hands on planting and Gardening even in his busy weekends.

Leave a Comment

You have an Idea. We have the Solution.

We help business evolve with lates technologies and infrastructures tailored to their needs and market trends.