AWS Service: Elastic Cloud Compute (EC2) Lab

cyber bert
4 min readSep 3, 2023

--

Purpose:
This will be a beginners walkthrough on how to navigate and use the EC2 service within AWS Management Console.

Credit:
This walkthrough I give credit to Stephaane Maarek who has a phenomenal course on AWS Certified Cloud Practitioner which is the foundational AWS certification. Of course, I narrate and give my thoughts and summaries at a more granular level to make this as user friendly as possible. Link to his course:
https://www.udemy.com/course/aws-certified-cloud-practitioner-new/

Overview:
EC2 is an IaaS (infrastructure as a service) that is versatile and widely used service within AWS that offers the following capabilities:
-Renting Virtual Machines (VM’s) EC2
-Stores data on virtual drives (EBS)
-Distributed load balancing across machines (ELB)
-Can scale the service using an auto-scaling group (ASG)

Configuration options:
Operating systems (OS) — Windows, Linux, MacOS
Configure compute power and cores (CPU)
Configure random-access memory (RAM)
Determine storage needs
a. Network-attached (EBS & EFS)
b. Hardware (EC2 Instance Store)
Network Card: speed of the card, Public IP address
Firewall rules: security group
Bootstrap script (configure at first launch): EC2 User Data

Bootstrap for EC2 User Data:
Bootstrapping means launching commands when a machine starts, in which this script is ran once at the first instance. (EC2 User Data script, ran in sudo with root access) This will allow for automated boot tasks to occur such as:
-Installing updates
-Installing software
-Downloading common files from the internet
-etc

EC2 instance overview:
You will need to choose an instance type which will depend on your requirements. See screenshot for examples. (Free Tier includes the low-end capabilities such as the t2 example shown below).

Up to 750 hours per month with Free Tier (ex: t2.micro instance)

EC2 hands-on tutorial:
Navigate to EC2 service, click on “Instances” tab, then click “Launch instances” button. Create the name or additional tags for the instance. Next, choose your desires application and OS image. In this tutorial we will select from the “Quick Start” section “Amazon Linux”. We will use the Free tier eligible AMI (Amazon Machine Image) of “Amazon Linux 2023 AMI” with the 64-bit architecture.

Now choose your instance type, we will use t2.micro (free tier). Review the instance type options and review the CPU and Memory to pick the desired instance.

The “Key pair (login)” section is used if you will utilize SSH to access your instance. We will be utilizing this feature. To enable we need to click “Create new key pair”. Now name your new key pair and select the key pair type (select RSA for tutorial), and select your “private key file format” (select “.pem” for Windows 10+, MacOS, Linux otherwise Windows less than 10 you need to select “.ppk” which is used for PuTTy). Click “Create key pair”.

You can leave the default setting on the “Network settings” section alone for the tutorial, but you can edit as needed. In this tutorial do check “Allow HTTP traffic from the Internet” (we are launching a web server).

You can leave the “Configure storage” as is with the default settings. You can edit and update per your requirements.

Lastly, we have the “Advanced details” section. For the purpose of this lab we can disregard majority of this section and scroll down to “User data” section. User data is used for when we pass script commands to our EC2 instance to execute on our first launch of our EC2 instance. We ideally have the desired script created for our intended purpose. Type the script to run this code when the instance first starts:

The “Summary section” shows the overview to double-check our selections. Then once satisfied click “Launch instance”. Once finished click “View all instances”. Wait until you see the Instance state as “Running”, make take a few seconds. If you click the checkbox for your instance you can then see the details such as the instance ID, IP addresses (internal and external) as well as other useful information such as security, networking, storage, etc.

Now, lets access our new instance by navigating the the Public IPv4 address provided in the details section. If you did everything correctly you should see the Hello World from IP and region displayed in the web page. Now you have a web server running! Keep in mind based on our configuration this should be accessible only via HTTP. If you need to stop the instance at any time, navigate back to the “Instances” dashboard for your EC2 instance and update the “Instance state” to “Stop instance”. You want to stop the instance so that you are not paying un-necessarily! You can also “Terminate instance” to delete the instance altogether. Go ahead and “start instance” again, now recognize the instance has a new IP and will not work with the previous IP assigned. Go ahead and review the details section “Public IPv4 address” for the new IP to put into your web browser. Keep in mind the private (internal) IP will remain the same throughout.

Conclusion:
We were able to configure and run our first EC2 instance! You can certainly get more granular and tailor based on your own needs. I will create more tutorials on EC2 for further insight and hands-on practice.

--

--

cyber bert

My career and passion lies within technology and more specific Information Security. With this blog I will share any Cyber Security topics of interest.