Module 2: Creating an EC2 Instance
You will create an Amazon EC2 instance to run your Drupal site
In this module, you will create an Amazon EC2 instance to run your Drupal site. Amazon EC2 provides highly-configurable server instances on-demand. On an EC2 instance, you can run a Drupal site that will be accessible by users anywhere.
Why use Amazon EC2 for your Drupal site
When getting started with Drupal, you may test it out by installing and running it on your laptop or desktop. This is fine for a test but you will quickly hit its limitations. Your Drupal site will only be running as long as your laptop or desktop is running. Further, the site will only be accessible by you -- it won’t be available over the public internet.
A better approach is to use a server. In the steps below, you will launch an EC2 instance to host your Drupal site.
Choosing an Amazon Machine Image
To create your EC2 instance, go to Amazon EC2 in the AWS console. Click the blue button that says Launch instance to open the instance creation wizard.
In the first page, you will choose an Amazon Machine Image (“AMI”). The AMI you choose will determine the base software that is installed on your new EC2 instance. This includes the operating system (Amazon Linux, Red Hat Enterprise Linux, Ubuntu, Microsoft Windows Server, etc.), as well as the applications that are installed on the machine.
The Amazon Linux distro is a popular choice, so choose the first option in the AMI selection view.
Choosing an instance type
On the second screen of the EC2 wizard, you will select an EC2 instance type. An instance type is a particular configuration of CPU, memory (RAM), storage, and network capacity.
AWS has a huge selection of instance types that cover many different workloads. Some are geared toward memory-intensive workloads, like databases and caches, while others are aimed at compute-heavy workloads like image processing or video encoding.
Amazon EC2 allows you to run 750 hours per month of a t2.micro instance under the AWS Free Tier. Select this option for this lab so that you won’t incur any costs on your bill.
After selecting the t2.micro instance, click the blue Review and Launch button to skip some of the advanced configuration steps.
Configuring a security group
After clicking the Review and Launch button, you will be at a Review Instance Launch screen. You need to configure one more thing before launching your instance.
Security groups are networking rules that describe the kind of network traffic that is allowed to your EC2 instance. You want to allow two kinds of traffic to your instance:
- SSH traffic from your current IP address so you can SSH into your instance and configure Drupal;
- HTTP traffic from all IP addresses so that users can view your Drupal site.
To configure this, click the Edit security groups link on the review page.
It will show the current rules in your security group.
There is an SSH rule configured, but it allows SSH access from any IP address. Click on the dropdown under Source to restrict it to your current IP address.
Then, you need to add a new rule to allow HTTP traffic. Click the Add Rule button.
In the new rule that shows up, click the dropdown under the Type column. Select HTTP, and it will autofill default values for an HTTP rule.
Once you have the security group rules in place, give your security group a name in the Security group name input box. Name the group “drupal”, so that it will be easy to find.
Once you’ve named it, click the blue Review and Launch button.
Launch and get an SSH key
It is now time to launch your EC2 instance. Click the blue Launch button to create your EC2 instance.
A modal will pop up to configure a key pair for your instance. You will use the key pair to SSH into your instance, which will give you the ability to run commands on your server.
Create a new key pair for your instance and give it a name. Then click the Download Key Pair button to download the .pem file to your machine, which you will use in the next module.
Once your key pair is downloaded, click the blue Launch Instances button to launch your EC2 instance.
You have successfully launched your EC2 instance. In the next module, we will configure your RDS database to work with your EC2 instance.