EC2 Instances#
With a VPC, subnets, and a key pair in hand, we’re ready to launch our first AWS server instance.
Elastic Cloud Compute (EC2) is AWS’ flagship service for running servers on their infrastructure. It’s their answer to questions like:
- How do I get a Linux or Windows box in Amazon’s cloud?
- How do I provision dedicated hardware?
- How do I build a server with a GPU attached?
Let’s create an instance and look at the choices we have to make along the way.
Assignment#
Launch a t3.micro EC2 instance named patientping-web in patientping-public-a.
Cost check: The Linux server we provision here will cost $0.0104 per hour (in us-east-1). That means about $0.25 per day, or $7.60 per month. If you’re on the free tier, it will be covered by that.
Remember to delete this server when you’re done with it!
- Navigate to “EC2” using the search bar at the top of the AWS Console.
- Click on “Instances” in the left-hand menu.
- Click the orange “Launch instances” button at the top of the table.
- Set up the server with the following options:
- Add a
Nametag with a value ofpatientping-web. Note that this is case-sensitive. - Use the default “Amazon Machine Image” (AMI; we’ll talk about this later). It should be “Amazon Linux.”
- Use
t3.microas the instance type. You may have to type the first few characters into search to get it to pop up. - Select our
patientping-keykey pair.
- Add a
- In the “Networking” section, click “Edit” in order to update a few things.
- Select the
patientpingVPC. - Select the
patientping-public-asubnet we created earlier. - For “Auto-assign public IP,” set
Disable. - For the “Firewall (security groups)” section, select “Create security group.”
- Name the security group (SG)
patientping-empty(we’ll add rules later). - Set the SG description to
Placeholder security group for PatientPing server(this is arbitrary, but a description is required). - Click “Remove” next to any rules that were created by default – there should be an SSH rule to remove.
- Don’t bother with “Advanced network configuration.”
- Select the
- Storage: leave the default configuration.
- Advanced details: leave the default configuration.
- Click “Launch instance.”
- You should see a message like
Success: Successfully initiated launch of instance (i-123123123).
Go back to the “Instances” list and confirm the new patientping-web server is there.
Tip#
If you want to use the CLI instead, here’s the command structure:
aws ec2 run-instances --image-id AMI-ID --instance-type TYPE --key-name KEY-NAME --subnet-id SUBNET-ID --security-group-ids SG-ID --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=INSTANCE-NAME}]'AMIs and Instance Types#
Let’s talk a bit more about the choices we made when launching that EC2 instance.
We chose the “Amazon Linux” AMI (Amazon Machine Image) to boot our virtual machine. This contains the baseline software for the server. Most AMIs just include an operating system like Ubuntu Linux or Windows Server 20XX, while others include full software stacks from a vendor.
You can also make your own AMIs, which is helpful if you’re going to be repeating the same configuration over and over again (we’ll talk about autoscaling later) or moving a server to a different region. It’s a full VM image, not just a container (like Docker)!
We then chose an instance type to use. This just defines what hardware resources are attached to our server. Think CPU, memory, GPU, the type of processor/networking card, etc.