Tag Archives: EC2

Amazon Web Services: How to Use ec2-api-tools to Manage EC2 Instances

Amazon Web Services provide a free usage tier to allow new users to trial many aspects of the offering for 12 months without charge. There are many benefits to this tier, and it is ideally suited to small-scale deployments or for just learning about AWS and EC2. At the time of writing, among the benefits of this tier are 750 hours of compute time for a t1.micro instance, along with 30GB of elastic block store (EBS) storage. So - I can run up 750 hours of CPU time using as many t1.micro instances as I want, as long as I stay within various other confines imposed by the tier.

30GB free EBS storage doesn’t go far if you use EBS-backed instances. EBS provides persistent storage, and with EBS-backed instances, the ability to shutdown and start up your instances. The alternative to the elastic block store is the instance store. Instance store-backed instances are launched, and must be left running. The storage is ephemeral and all changes will be lost (well - the entire instance is lost) when the instance is terminated. Note the terminology - terminated means just that - that the instance will be halted, and marked for deletion. The only way to have persistence is to use EBS-backed AMIs, which is obviously my preference.

This article will cover the provisioning of instances and volumes via the command line. For this, the Amazon EC2 API Tools can be used. These tools are Java-based, so an appropriate JDK must be used.

Essentially, the EC2 tools interact with the Amazon EC2 API using X.509 certificate-based authentication, and provide functionality much the same as the web-based EC2 Management Console. This allows for quick interaction with instances, automated monitoring, automation ability, and so on.

The article assumes that you have already signed up for Amazon Web Services, familiarised yourself with the concepts and functionality of the EC2 Management Console, and have generated and downloaded the following:

  • X.509 Certificate Pair (Public Certificate, Private Key)
  • SSH Private Key

You can create your X.509 certificate pair and download it via the AWS Management Console -> Your account name in menu bar -> Security Credentials. You can generate your SSH Private Key via the EC2 Management Console -> Network & Security -> Key Pairs. The SSH Public Key will automatically be installed on any instances provisioned so that you can log in.

Continue reading

AWS: Ruby on Rails Deployment Part 2: Ruby, RubyGems, Rails, Thin and Nginx

The previous article in this series has left us with a minimally-configured Nginx installation running on an EBS-backed Ubuntu EC2 instance.

This article will pick up where we left off. The latest versions of Ruby and RubyGems will be downloaded and installed. Then the Rails and Thin gems will be installed. Nginx will then have the final configuration changes applied to enable it to proxy through to the Thin workers. Thin is a lean Ruby-based web-server that has been designed to replace Mongrel (which was the standard Ruby web server until development ceased), and uses various components lifted from Mongrel (e.g. the parser - giving us the same (or better?) speed and security as Mongrel).

It’s been a while since I deployed Ruby on Rails - and that was using Mongrel - so let’s see how Thin matches up.

Continue reading

AWS: Ruby on Rails Deployment Part 1: Nginx Installation and Configuration

Over the course of this series of articles, I will cover the build and configuration of an Amazon EC2 Instance capable of serving Ruby on Rails applications. The series will cover the build and installation of Nginx from source, virtual host and proxy configuration within Nginx, installation of Ruby and RubyGems, installation of the Rails and Thin gems, and the deployment of a set of clustered Thin workers. I chose Nginx over Apache HTTPD as it is renowned for both performing very well as a reverse proxy as well as serving static content whilst having a very low memory footprint. Plus, I’m always interested in looking at “alternative” software solutions to common problems.

Read my article around EC2 instance management via the ec2-api-tools if you’d like to provision your instance(s) via the command line, otherwise just provision your instance(s) via the EC2 Management Console. This article presumes that you have an instance running and ready to go. I used ami-08df4961 (which is Ubuntu 12.10 i386 Server, EBS-backed). I’d use a RHEL instance but they are not eligible for the free tier due to licensing, plus the Ubuntu instances are very well supported by Canonical.

Continue reading