Configuring AWS for Rails Deployments

Tutorial 2 of 5

1. Introduction

This tutorial aims to guide you in configuring Amazon Web Services (AWS) for deploying Rails applications. Amazon Web Services provides a highly reliable, scalable, and low-cost infrastructure platform in the cloud, that powers hundreds of thousands of businesses. By the end of the tutorial, you should be able to:

  • Set up an AWS account and an EC2 instance
  • Install and configure Rails on your AWS instance
  • Deploy a Rails application to AWS

Prerequisites

  • Basic knowledge of Ruby on Rails
  • An AWS account. If you don't have one, you can sign up here

2. Step-by-Step Guide

Step 1: Setting Up an AWS EC2 Instance

  1. Log into your AWS account, go to the EC2 Dashboard and click 'Launch Instance'.
  2. Choose 'Ubuntu Server 18.04 LTS' as your instance type (this is a free tier).
  3. Choose an instance size. t2.micro is free and should be sufficient for our needs.

Step 2: Configuring the EC2 Instance

After your instance is up and running, you need to install the necessary software. SSH into your instance and install the following:

  1. Update the package lists for upgrades and new package installations:
sudo apt-get update
  1. Install curl:
sudo apt-get install curl
  1. Install RVM (Ruby Version Manager) with Ruby:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
source ~/.rvm/scripts/rvm
  1. Install Node.js, a Javascript runtime:
sudo apt-get install -y nodejs
  1. Install Yarn, a package manager for Javascript:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
  1. Install Rails:
gem install rails

3. Code Examples

After setting up an environment for Rails, you can create a new Rails application by running:

rails new my_app

This will create a new Rails application under a directory named my_app.

4. Summary

In this tutorial, we've walked through the process of setting up an AWS account, creating an EC2 instance, and installing Rails on that instance.

5. Practice Exercises

  1. Try deploying an existing Rails application to your AWS instance.
  2. Experiment with different AWS instance types and sizes.
  3. Try installing a different version of Rails on your instance.

Additional Resources