This post is going to show you how to deploy a Ruby on Rails application to Elastic Beanstalk on Amazon Web Services. This is called pushing your application live.

What is Elastic Beanstalk?

Elastic Beanstalk is a service that allows you to host your application in the cloud without worrying about the infrastructure required to do so.

How much does it cost?

Elastic Beanstalk is free. However the services it uses are billable.


This guide assumes you have created an account with Amazon Web Services and you have a Ruby on Rails application ready to deploy! You should also be familiar with Git and the Command Line.

Create a Network for your Elastic Beanstalk Environment

In order to run a Rails application in Elastic Beanstalk, you need an EC2 instance of type t2.micro or greater. Keep in mind when you choose Ruby as your platform in Elastic Beanstalk you are simply choosing Ruby as the platform - not the Rails gem specifically. So although you might be able to use a smaller instance size to launch a Ruby sample project, it may not run Rails.

Some instance types require a VPC - t2.micro requires it. VPC stands for Virtual Private Cloud and the best way to think about it is simply a network in the cloud. You choose the IP range and subnets and whether or not it will have access to the internet. You will likely only have to create a VPC once. You can use the same VPC for Elastic Beanstalk deployments. In fact, you can use the VPC for any services in AWS. You can read more about VPC’s in What is Amazon VPC?

TLDR: Rails needs at least a t2.micro instance type. t2.micros need VPCs

Step 1: Create a VPC

  1. Go the the VPC Console in AWS
  2. Choose Your VPCs
  3. Click Create VPC
    • Name your VPC: myapp_dev
    • Use\16 for your IP range (This can’t be changed)
    • Click Create
  4. You need to Enable DNS Hostnames (You will need this for your database)
    • Select your new VPC from the list
    • From the actions menu, choose Edit Dns Hostnames
    • Check enable for Dns Hostnames
    • Click Save
    • Click Close

Step 2: Create an Internet Gateway and Attach it to your VPC

You have just created a Virtual Network! Problem is this network has no way of connecting to the internet, so let’s add an Internet Gateway to make that happen.

  1. Go the the VPC Console in AWS
  2. Choose Internet Gateways
  3. Click Create internet gateway
    • Name your gateway: myapp_dev
    • Click Create
    • Click Close
  4. You need to attach your gateway to your VPC
    • Select your gateway from the list (It should say detached)
    • From the actions menu, choose Attach to VPC
    • Choose your VPC from the dropdown
    • Click Attach

Step 3: Edit the Route Table for your VPC

  1. Go the the VPC Console in AWS
  2. Choose Your VPCs
  3. Find your VPC in the list and click the id listed under Main Route table
  4. Notice the list has been filtered by that id
  5. Choose the tab labeled Routes
  6. Click Edit Routes
    • Click Add route
    • Enter for the Destination
    • Choose Internet Gateway and select your Internet Gateway
    • Click Save routes
    • Click Close

Step 4: Create a Subnet for the VPC

  1. Go the the VPC Console in AWS
  2. Choose Subnets
    • Name your Subnet: myapp_dev_1
    • Choose your VPC
    • Enter for the IP range
    • Click Create
    • Click Close

Congratulations! You have completed creating the network required by the t2.micro instance type we will use in our Elastic Beanstalk environment.

Create your Elastic Beanstalk Application

TODO: Application names vs. environments

  1. Go to the Elastic Beanstalk Console in AWS
  2. Click Create New Application
  3. Name your application: myapp
  4. Click Create
  5. From the actions menu choose Create environment
  6. Choose Web server environment
  7. Click Select
    • Name your environment: myapp-dev
    • Choose a domain: myapp-dev
    • Choose Ruby for the platform
    • Click Configure more options
  8. Review Instance configuration
    • If the instance type is not t2.micro…
    • Click Modify
    • Choose t2.micro for the Instance Type
    • Click Save
  9. Review the Network configuration
    • Click Modify
    • Choose your VPC
    • Select your Subnet
    • Click Save
  10. Click Create environment

It will take some time for the environment to be created. Once it is finished you should see a green check mark on the Dashboard. If you do, Congratulations! You should be able to click the URL on the dashboard and view the sample project homepage.

Next you are going to want to push your own project to this environment. I’ll show you how to do that in the next post: Installing and Configuring the Elastic Beanstalk CLI to Deploy a Rails 5 Application