Seven Steps to Launch an Amazon EC2 Instance
Tags: aws, cloud, beginners, devops
Published: 2024-03-19 21:47:14


Learn how to launch an Amazon EC2 instance in seven simple steps. This easy-to-follow guide will walk you through the process, ensuring that you have a successful launch every time. 

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure and resizable compute capacity in the cloud. we can use it to provision virtual servers that are called Amazon EC2 instances, which can handle almost any computing need.

With Amazon EC2 we can do the following:

• Provision and launch one or more EC2 instances in minutes.

• Stop or shut down EC2 instances when we finish running a workload.

• Pay for only the compute time that we use when running an instance.

In this blog, you will learn about the seven steps to launch an Amazon EC2 instance.

## Step 1: Tags
The first step in creating an instance is assigning it a name and tags. This step is optional but recommended. The name of an instance is a default tag for the Instance name and works like every other tag. Tags work as metadata to identify and define the AWS resources that they are attached to. Tags simplify our search for tagged resources based on a specific tag key or tag value. we can also filter our searches by multiple tag keys or tag values.

## Step 2: Choosing an Amazon Machine Image
The next step in launching an instance is choosing the AMI. An AMI is required when launching an EC2 instance. The AMI has three main components. First is the template for the root volume, which contains the operating system, application servers, and applications. Next is the launch permissions that control which AWS accounts can use the AMI. Finally, there is a block device mapping that specifies the volumes to attach to the instance, if any, when it is launched.

We can launch multiple instances from a single AMI when we need multiple instances with the same configuration. In this way, all of the instances launched from the same AMI will be identical except for their IP address.

## Step 3: Choosing Instance Types
After we choose the AMI for launching the instance, the next step is to choose an instance type. The instance type specifies the hardware of the host computer that's used for our instance, such as CPU, memory, storage, and networking capacity. Amazon EC2 provides a selection of instance types that these components optimize to fit different use cases. we can select the appropriate instance type based on the requirements of the application or software that we plan to run on our instance.

Each instance type belongs to an instance family. An instance family is a group of instances with varying configurations that are based on similar compute, memory, and storage capabilities. Within each family, instance types have specific names. For example, the T family has specific instance types such as t2.micro and t3.large.

## Step 4: Key Pairs
The next step involves a decision about using a key pair. A key pair consists of a public key and a private key. It is a set of security credentials that we use to prove our identity when connecting to an Amazon EC2 instance. Amazon EC2 stores the public key on our instance, and we are responsible to store the private key.

To connect to a Windows instance, use the private key to obtain the administrator password. Then, log in to the EC2 instance's Windows Desktop by using Remote Desktop Protocol (RDP). With Linux instances, at boot time, the public key content is placed on the instance. To log in to our Linux instance, we must provide the private key when we establish the connection.

## Step 5: Network Settings
The next step in launching our EC2 instance is to configure our network settings. This means choosing the VPC, subnet, and security group that we will place our instance in. We also must decide whether we will enable or disable a public IP address for the instance. The instance is placed behind a security group, within a subnet, within a VPC, within a Region.

The Region that we are launching our instance into is assumed by the Region that we are working in on the AWS Management Console. It cannot be changed from within the Amazon EC2 launch wizard.

### Choosing VPC
When we start using Amazon VPC, we have a default VPC in each AWS Region. A default VPC comes with a public subnet in each Availability Zone of the Region. Therefore, we can immediately start launching Amazon EC2 instances into a default VPC.

### Public IP Address
Next, we must decide whether we want a public IP address assigned to the instance. A public IP address is an IPv4 address that's reachable from the internet. We can use public addresses for communication between our instances and the internet. 

### Security Group
Next, we need to choose the security group. A security group acts as a virtual firewall that controls network access to our instances. At the most basic level, a security group is a way for us to filter traffic that is allowed to reach our instances. Security groups are based on rules that we can configure to filter the traffic that is allowed for our instance. Security groups block all access unless an allow rule is in place for that traffic. 

## Step 6: Configure Storage

Next, we must configure the storage volume for our instance. The main solution for EC2 instance storage is Amazon Elastic Block Store or Amazon EBS. Amazon EBS volumes provide durable, detachable, block-level storage for our Amazon EC2 instances. It's basically an external hard drive.

### Amazon Elastic Block Store
As EBS volumes are mounted to the instances, they provide extremely low latency between where the data is stored and where it might be used on the instance. For this reason, EBS volumes can be used to run a database, host applications, and handle storage operations for almost any computing need.

### Amazon EC2 Instance Store
AWS offers another option for root volume storage for EC2 instances called Amazon EC2 instance store. The instance store is designed for temporary storage. Instance store has many limitations. When we spin up an instance by using the instance store, the volume is physically attached to the host computer.

Instance store volumes cannot be configured for the volume type (SSD or HDD) or the volume size. These configurations are determined based on the instance type that we use. Also, encrypting and retaining the volume after we delete the instance is not an option. Instance store volumes are ephemeral and retain data only while the instance is running or rebooting. 

## Step 7: Advance Details

The final element of launching our EC2 instance is configuring the advanced details. In this module, we will review only some of the more common advanced settings options. Next, we'll start with AWS Identity and Access Management (IAM) roles.

### IAM Roles
It is common to use EC2 Instances to run an application that must make secure API calls to other AWS services. To support these use cases, AWS gives us the ability to attach an IAM role to an EC2 instance. The IAM role then grants permission to the instance to make API requests to the other service, based on the policy attached to the role.

### Managing IAM Roles
To attach a role to an instance, select a role from the instance profile to associate with the instance. An instance profile is a container for an IAM role. When it comes to managing roles on our EC2 instances, we have a lot of flexibility. We can attach an IAM role when we launch the instance. Or, if we need to, we can also attach a role to an EC2 instance that is already running. We can also remove roles from an instance. If we modify a role's policy, the change goes into effect for all instances that have that same role attached to them.

### User Data
Next, we’ll look at user data. When we create our EC2 Instances, we have the option of passing user data to the instance. The user data section lets us copy in a script that can automate the completion of installations and configurations at instance launch. For example, a user data script might patch and update the instance's operating system, fetch and install software license keys, or install additional software.

### Termination Protection

If termination protection is enabled, the instance cannot be terminated by using the console, API, or CLI until termination protection is disabled. If no value is specified, the value of the source AMI will still be used.

### Tenancy 

Dedicated tenancy instances run on single-tenant, dedicated hardware. Host tenancy instances run on a dedicated host. If we select dedicated tenancy or dedicated host, The costs will be increased for our instance. We have no additional charge for running our instance on shared hardware. If no value is specified, the value of the source AMI will still be used.

Finally, we are now fully prepared to launch an Amazon EC2 instance.

This is the second blog post of the Getting Started With Cloud series so if you liked it, you can follow me, and comment down your thoughts ❤️

#### Let's stay in touch:
Connect with me on [LinkedIn] (https://www.linkedin.com/in/rajputjayesh) to stay updated! 🔗 Follow me on [Dev.to](https://dev.to/rajputjayesh) for more such content ✅