Regular users of SUSE Studio have probably discovered the new Amazon Elastic Compute Cloud (EC2) build format that we sneaked in last week. It was available for openSUSE 11.3 only, and today we released it for SUSE Linux Enterprise Server (SLES) 11 SP1 as well. Support for SLES 10 SP3 will be available next week.
This means you can now easily build customized server appliances for Amazon EC2 in SUSE Studio! Together with Amazon's recent free usage tier announcement, there's hardly a better time to try out EC2.Introducing Amazon EC2
If you're new to Amazon EC2, it's a web service hosted by Amazon that provides dynamically scalable computing capacity. It is cloud computing and sometimes also referred to as Infrastructure as a Service (IaaS). EC2 allows you to rent reliable computing resources (eg. CPU, memory, disk storage) in a highly flexible and affordable manner, with prices starting at just several cents per hour per instance. These resources can be quickly scaled up or down on demand, reducing or even eliminating the need for companies to buy and maintain expensive server farms in-house. Before we proceed with building an EC2 image in SUSE Studio, there's some Amazon specific terminology we should clarify. An appliance must first be created as an Amazon Machine Image (AMI) before it can run in EC2. There are two main types of AMIs:
There are several key differences between these two AMI types, though we won't go into the details in this post. What's important to note now is that the EC2 images built by SUSE Studio can technically be used to create both AMI types. To keep things simple, however, the current AMI creation script only supports S3-backed AMIs for openSUSE based images, and EBS-backed AMIs for SLES based images.Building Amazon EC2 images with SUSE Studio
The easiest way to get started is to find an existing EC2 image in SUSE Gallery, such as this LAMP Server appliance. But let's walk through the steps to create one from scratch. First login to SUSE Studio and create a new appliance based on openSUSE 11.3 JeOS:
Choose your preferred architecture (note that 64-bit S3-backed AMIs are slightly more expensive to run), change the default appliance name, and hit "Create appliance". You will now be in the appliance editor interface where you can perform the usual software selection and configuration, but we'll skip that for now and jump to the Build tab. Change the default image format to "Amazon EC2 image":
There's now an alert in the left sidebar, telling you to add the Amazon EC2 software repository before building:
Simply click on the "Add the 'Amazon EC2 Updates' repository" link there, which will then add the required repository in the software tab:
Once you're satisfied, return to the Build tab and hit "Build". It usually takes only about five minutes (!!) for the build to complete:
Now we can use this image to create an AMI in EC2.Creating an S3-backed AMI from the Studio-built image
We are working on a minimal user interface to do this directly from SUSE Studio, so meanwhile you have to download the EC2 image and execute the bundled AMI creation script. To do this, click on the "Download" link in the Build tab to download the EC2 image archive. Extract the archive and you'll find the create_ami.sh script and README files along with the EC2 image:
If this is your first time using the Amazon AMI tools, you'll need to do some configuration. The steps are explained in the README file, but I'll repeat them here with a bit more details. First download and install the Amazon EC2 AMI and API tools. Now add your Amazon Web Services (AWS) account information in the following environment variables:
- $AWS_USER_ID. AWS user ID (eg. 123456789012)
- $AWS_ACCESS_KEY. AWS access key ID (eg. ABCDEFGHIJKLMNOPQRST)
- $AWS_SECRET_KEY. AWS secret access key (eg. abcdefghijklmnoprqrtuvwxyzabcdv)
- $EC2_CERT. Path to EC2 X.509 certification (eg. ~/cert-aws.pem)
- $EC2_PRIVATE_KEY. Path to EC2 private key (eg. ~/pk-ec2.pem)
Launching new instances of your Studio-built AMI
You can launch as many instances of an AMI as you like. Note that the AMI (referenced by the AMI ID) exists only in the region that it was created in. One way to launch new instances of your AMI is with the command line tools, eg: ec2-run-instances ami-6a380d1e -t m1.small --region eu-west-1 -k jamestyj-eu. You'll want to create your SSH keypair in Amazon first if you don't already have one (specified by the -k option) as password based authentication is automatically disabled (hence the root and user passwords configured in Studio no longer apply). Wait for the instance to boot and check for it's DNS name with ec2-describe-instances, and then you can ssh into it once it fully boots up, eg: ssh -i ~/ec2-eu firstname.lastname@example.org. Don't forget to terminate the instance when you're done (eg. ec2-terminate-instances).
To help manage your Amazon EC2 and S3 accounts, we recommend using the ElasticFox and S3Fox Firefox plugins. These plugins have an easy to use graphical user interface that allow you to quickly have an overview of your Amazon accounts, launch new instances, terminate existing ones, etc. Here's a screenshot of ElasticFox:
And one of S3Fox, which is particularly useful for cleaning up any leftover image files from de-registered S3-backed AMIs:Credits: The ElasticFox and S3Fox screenshots were taken from here.
SUSE Linux Enterprise Server in Amazon EC2
Amazon EC2 has recently collaborated with SUSE to provide supported instances of SUSE Linux Enterprise Server (SLES) running in EC2. These instances have automatic maintenance and access to security updates, patches, and bug fixes.Creating an EBS-backed AMI
SLES based EC2 instances are currently available as EBS-backed AMI only (otherwise it will not be able to get access to the updates). The creation of these EBS-backed AMIs is very similar to S3-backed ones (as it's all handled by the bundled script), except that the script is called create_ebs_ami.sh. This blog post is getting a bit too long, so we'll go into the details in a later post.
Update 1 (Oct 27 21:26:18 CEST):
Update 2 (Nov 01 09:55:18 CEST): The 32-bit PAE-enabled EC2 building issue is now fixed.