EC2 — AWS Solution Architect Associate Series — Part 2

Ata Erdemir
6 min readJan 31, 2024

--

Hello everyone! In my previous post, we started the AWS Solution Architect Associate Series. In this post, we will cover topics such as how to launch an EC2 instance in the simplest way and what kind of configurations can be made. So, let’s get started!

What is EC2?

https://awsegitimi.com/tr/blog/1354/amazon-ec2-nedir-ec2-neden-bu-kadar-onemlidir-ec2-/

First of all, we need to understand what EC2 is. EC2 stands for “Elastic Compute Cloud” and is a service that Amazon Web Services (AWS) offers virtual servers. EC2 is designed to provide scalable and flexible computing capacity in the cloud computing environment.

According to Amazon’s definition, “Amazon Elastic Compute Cloud (Amazon EC2) is a virtual server service that provides secure, resizable compute capacity in the cloud. Simply put, it is a machine with an operating system and selected hardware components of your choice, but entirely virtualized.”

To highlight its basic features:

1. Virtual Servers (Instances): EC2 provides users with pre-configured virtual servers that can scale according to the user’s needs.

2. Various Processor and Memory Options: EC2 offers different processor types, memory sizes, and storage options. Users can choose virtual servers that best suit their needs.

3. Scaling: Users can replicate or reduce their virtual servers based on their requirements. This allows for instant response to demand and the opportunity to optimize costs.

4. Custom Amazon Machine Images (AMIs): Users can launch EC2 instances using their application and configurations by utilizing custom AMIs.

5. Different Operating Systems: EC2 supports various operating systems, including Windows and various Linux distributions.

6. Security Groups and Key Pairs: EC2 users can manage their virtual servers securely by implementing security measures such as security groups and SSH key pairs.

Amazon EC2 offers a flexible and scalable solution suitable for a wide range of applications, providing users with the flexibility to meet their needs.

EC2 Instance Kurulumu

There are multiple ways to launch a virtual machine, and one of them is to configure and start the machine using the EC2 interface through the management console with buttons, i.e., GUI.

To initiate the process of starting an EC2 instance through the interface, you can first click on the “Launch Cloud Server” section. The next screen that appears is where you will make the necessary configurations for your EC2 instance.

In this field, you are being asked for a name for your server. As a commonly recommended “Best Practice,” it is advisable to name the server based on the purpose for which it is being launched.

In this field, you are prompted to select an operating system for the EC2 instance. Most of the options you see in the visual above are labeled with the indication “Free tier eligible,” except for macOS, and do not incur any charges during usage.

Next, you will come to the section where you need to choose the type of your cloud server. This area includes infrastructure details for your cloud server, such as vCPU, Storage, and Memory (RAM). While these have various types tailored for specific use cases, a significant portion of them comes with associated costs.

You might be wondering what “t2.micro” represents in this context; let me clarify that right away. The “t2.micro” is equivalent to the example I will provide in the visual below. In the example, only a cloud server type with greater capacity has been selected and named differently.

First position — The first position, “c” (equivalent to “t” in the server we selected), indicates the instance family. This signifies that this instance belongs to a family optimized for compute.

Second position — The second position (5) indicates the generation of the instance. This example belongs to the fifth generation of instances (t2).

Letters before the period — In this case, “n” denotes additional features such as local NVMe storage.

After the Period — After the period, “xlarge” specifies the instance size. In this example, it is xlarge (t2.micro).

In the next step, you will encounter a Key Pair field for security purposes.

As seen from the description in the visual, you will be creating a Key Pair that you can use for secure remote connections to your cloud server.

As the final step, you will access the section where the network settings for your server will be configured.

If you accept it as it is, it will launch with the “default” settings. However, if you want to customize the settings yourself, you can click on the “edit” section in the upper right corner to make adjustments.

Each server comes with a new security group (think of it as firewall settings) and is pre-named. You can specify the type of access, protocol, and port from the inside, and finally launch it. However, before launching, there is one more setting you can configure. In this final setting, there is an area where you can manually enter the storage amount. I’m providing the visual below.

However, the crucial point here is that if you exceed the criteria for “free tier eligible” that you have selected, charges will be incurred based on your usage.

Up to this point, you can configure everything from license settings to kernel identity and upper data version from the boot options. However, the main point I want to highlight is the area I’ve shown below, which allows you to define pre-settings with your own Bash script and launch the server.

Bash script:

#!/bin/bash -ex
wget https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/FlaskApp.zip
unzip FlaskApp.zip
cd FlaskApp/
yum -y install python3-pip
pip install -r requirements.txt
yum -y install stress
export PHOTOS_BUCKET=${SUB_PHOTOS_BUCKET}
export AWS_DEFAULT_REGION=<INSERT REGION HERE>
export DYNAMO_MODE=on
FLASK_APP=application.py /usr/local/bin/flask run --host=0.0.0.0 --port=80

Afterward, in the field below, your machine will be preparing to come up in the pending position.

In this way, we have successfully launched a basic AWS EC2 server. In the next stage, I will explain AWS’s Shared Responsibility Model and how it works.

Thank you.

--

--

Ata Erdemir
Ata Erdemir

Written by Ata Erdemir

An ordinary security guy and coffee addicted!

No responses yet