Easy Launch Guide to AWS and EC2 Instances
AWS has arguably one of the largest and most diverse offerings of any cloud computing company. This variety comes at a cost: complexity. With all of the guides, documentation, and videos geared towards experienced users, getting started with AWS can very quickly become a nightmare. That’s why we wrote this quick and easy guide to getting your EC2 instances up and running.
Make sure you have an account set up with billing enabled on AWS.
Login to AWS and go to your console (below).
Click “Launch a virtual machine”.
Welcome to the EC2 dashboard! This is where you can see all of your active instances, manage spot requests, create snapshots, and much more.
Click “Launch Instance”.
Time to pick your Amazon Machine Image (AMI)!
The AMI is the operating system plus any additional packages required to fulfill a specific function. These functions can include building a website, running an API, or managing a database.
If you’re looking for an easy way to run Machine/Deep Learning frameworks, check out our AMI It’s Not That Deep. It comes pre-installed with everything you need to run your neural networks on CUDA GPUs.
For the purposes of this tutorial, we’ll be using a basic Amazon Linux 2 AMI, but you can use whatever you want.
Next, you’ll want to select an instance type. You can learn more about the different instance types here.
You can choose anything from general purpose t2s and t3s (for simple web applications, websites, and basic APIs), to high memory X1s (for in-memory databases, etc.), to GPU accelerated compute p2s and p3s (for machine learning and deep learning).
For this tutorial, we’re just going to be using a t2.micro instance, but you can, again, use whatever you like.
Click “Next: Configure Instance Details” when you’re done.
All of the below options are optional, we won’t be changing anything on the page for this tutorial, so skip these if you don’t need anything special. Click “Next: Add Storage” when finished.
Number of Instances: The total copies of the instance you want to launch.
Purchasing option: Requests your instance(s) as spot instances. This results in cost reduction in exchange for instance fidelity (it will sometimes terminate if there aren’t enough spot instances available).
Network: Set the virtual network group for this instance (basically virtual lan).
Subnet: Set the subnetwork of the virtual network group for this instance.
Auto-assign Public IP: Allows you to change how the public IP is chosen, default is auto-assigned.
Placement group: Determines how instances are placed in the underlying hardware.
Capacity reservation: Allows you to reserve space in a specific availability zone.
IAM role: Permissions for the management of the instance.
Shutdown Behavior: Dictates what the shutdown command will do to the instance.
Enable Termination Protection: Additional protection against terminating the instance.\
Monitoring: Enables notification and monitoring for your instance.
Tenancy: Choose whether you share your hardware or have your own dedicated servers.
Elastic Inference: Accelerates inferencing from machine learning models.
T2/T3 Unlimited: Enables autoscaling for t2 and t3 instances, letting you exceed usage briefly when needed.
Add or change any volume sizes or types, for this tutorial we will use a 100 gb SSD. If you’re on the free plan, you can use up to 30gb.
Click “Next: Add Tags” whenever you’re ready.
Add any tags for your own reference.
We won’t be adding any tags. Click “Next: Configure Security Group” when you’re done.
If you do not already have a security group, create one at this stage. Use whatever name and description you’d like.
Make sure that you have port with a type of “SSH”, a protocol of “TCP”, a port range of “22”, and a source of 0.0.0.0/0. When you get a chance, you should change the source to your ip address in order to improve security. (You may want to add additional gateways for http, https, and other requests if your server needs to take them)
If you already have a security group ensure that the rules match the above ruleset.
Click “Review and Launch” when ready.
Review your details, and make sure you’re ready to go.
A dialogue will pop up asking which “Key Pair” you’d like to use. A “Key Pair” is how you access your instance, it is basically your security certificate.
If you don’t have a key pair, select “create a new key pair”. Make the name whatever you like.
Click “Download Key Pair” and save it somewhere you can easily access it.
**IMPORTANT** DO NOT LOSE YOUR KEY PAIR. If you lose it, you will be unable to access your instance.
Click “Launch Instance” when you’re ready to continue.
A dialogue will pop up at the top of the screen to inform you that your instance is being provisioned. Click the instance ID to be taken to your management console.
When the instance state turns green and says “running” and the status checks have all finished (when they no longer say initializing), your instance is read to go!
Take a look at your description, that’s where you’ll find your public DNS. You’ll need this to login to your instance.
It will look something like this: ec2-your-instance-ip.compute-1.amazonaws.com.
Now, you have everything you need to login to your instance from a terminal.
From this point on, this guide assumes you are using either a Mac or Linux computer. If you are using a Windows computer, the instructions are similar, however, you may need to do some extra steps to set up ssh. There’s a great guide on this made by How-to Geek.
Open up terminal and use the directory command, cd, to go to the directory where you saved your key pair from Step 10 of the Launch Guide (probably your downloads folder, /Downloads on Mac).
Use the command: cd YOUR/FOLDER/PATH/HERE
Use ls in the console and ensure that you see your key pair from earlier in the directory.
Amazon doesn’t allow the usage of “public” keys due to security, so we’re going to have to change the permissions on your key using chmod.
Use the command: chmod 400 YOUR_KEY_NAME.PEM
Time to use the ssh command to login to your AWS instance.
You will need your key pair, your public dns, and your user name.
Your user name will vary depending on the AMI you chose in Step 4 of the Launch Guide.
Some Common Examples are:
For Amazon Linux 2 or the Amazon Linux AMI, the user name is ec2-user.
For a Centos AMI, the user name is centos.
For a Debian AMI, the user name is admin or root. For a Fedora AMI, the user name is ec2-user or fedora.
For a RHEL AMI, the user name is ec2-user or root.
For a SUSE AMI, the user name is ec2-user or root.
For an Ubuntu AMI, the user name is ubuntu.
For an It’s Not That Deep AMI, the user name is ubuntu.
Otherwise, if ec2-user and root don't work, check with the AMI provider.
Use the command: ssh -i YOUR_KEY_NAME.PEM USERNAME@YOUR-PUBLIC.DNS.COM
If this is your first time connecting to this instance, a dialogue will pop up asking you to confirm that you know the host, make sure it matches the Public DNS you entered in the last step.
Type ‘yes’ if it matches.
Welcome to your instance, from here you can run whatever shell commands you need.
If you need any more info or run into any problems, check out the AWS documentation on EC2 here.
Don’t forget to terminate your instance after you’re done.
Stay tuned for more guides centered around machine learning from the engineering team here at Lazarus.