Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is Amazon EC2?
2.1.
What is AWS Instance?
3.
Getting started with Amazon EC2
4.
What is AMI?
4.1.
Boot modes
4.2.
AWS Windows AMIs
4.3.
Find a Windows AMI
4.4.
Shared AMIs
4.5.
Paid AMIs
4.6.
AMI lifecycle
4.7.
Use encryption with EBS-backed AMIs
4.8.
Understand AMI billing information
5.
EC2 fleet
6.
Security in Amazon EC2
7.
Frequently Asked Questions
7.1.
What are the benefits of EC2?
7.2.
Is Amazon EC2 a virtual machine?
7.3.
What is the difference between ECS and EC2?
7.4.
How are VMs and instances different?
8.
Conclusion
Last Updated: Mar 27, 2024
Easy

Amazon EC2

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

There's no doubt that AWS will be around for a while, helping people with their computing needs. Among all AWS services, Amazon EC2 is the most popular and widely used service, making it one of the most comprehensive and widely welcomed Cloud platforms. With Amazon EC2, you can launch and manage server instances anytime you need. In this article, we will talk about AWS EC2 in detail.

What is Amazon EC2?

Amazon Web Services has created a new cloud service called EC2. In EC2, servers are provided that are customized to meet the user's needs. If you want to develop an application, there are two ways. We can either purchase our servers and perform the desired operations or use services deployed already in the cloud, so here we have a pre-configured server. As a result, we can deploy applications automatically through cloud services. Using EC2 is just like creating multiple servers or Virtual Machines. Compared to deploying on optimized servers, these can be initiated in a few minutes.

Compared to the traditional or the optimized servers, there is no upfront cost with EC2 since it operates on a monthly cycle. In contrast, optimized servers require a setup fee, but EC2 operates on a monthly cycle, so we don't pay any setup fees. Imagine you want to upgrade these servers from 2 to 8 cores of RAM.

What is AWS Instance?

A virtual environment on Amazon ECS is unconnected from the On-demand service's foundation. A user can thus rent an EC2 instance according to their needs and then connect/move the applications to it. Due to the above, Amazon EC2 instances enable you to easily adjust to the website traffic dynamics. AWS Ec2 instances also eliminate investing in and managing additional hardware and software.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Getting started with Amazon EC2

  1. Create an Amazon Web Services account and sign in. Login to Amazon Web Services using this link (here is the link). If you already have an account, sign in. If you don't, create one. Click the EC2 tab on the EC2 Dashboard. Then Launch Instance on the Amazon EC2 console.

 

 

2. On the Microsoft Windows Server 2019 Base row, click the "Select" button. Note that this will create a Windows instance and not a Linux one. The connections to the Instance will be affected by this.
 


3. You need to select t2 micro (free instance type). Then click "Review and Launch". Launch by clicking on Launch.
 


4. Create a new key pair by selecting "Create a new key pair". Fill in a key pair name in the box below ("Key pair name"). You can name your key anything you want, but I called CodingNinja. Select the key pair you wish to download. The key will be downloaded. Save it. Next, click on "Launch Instances".


5. It has now been launched. Return to the Amazon EC2 console. Before proceeding to the next step, wait until you see that "Instance State" is running. Then, click on Connect.
 

This tutorial used a free tier instance. However, I would recommend terminating it before moving on.

What is AMI?

Amazon Machine Images (AMIs) are master images created by Amazon Web Services (AWS), which can be used to create virtual servers (EC2 instances).

In the machine, images are included in an operating system and other software that determines the user's operating environment. There are several different AMI types, based on geography, operating system, system architecture -- 32- or 64-bit -- permissions for Launch, and if the AMI is backed by an instance store or Amazon Elastic Block Store (EBS).

As part of each AMI, there's a template for the root volume. It can be anything from operating systems to applications. Also, only the correct AWS accounts are allowed to launch AMIs. When block device mapping is used, instances are associated with the right volumes.

Boot modes

Instances can be launched using different boot modes using the AMI boot mode parameter. EC2 attempts to launch the Instance on UEFI when the boot mode parameter is set to UEFI. An instance launch might fail if UEFI is not enabled on the operating system.

UEFI and legacy bios are available as boot mode parameter values for an AMI. Not all AMIs contain a boot mode parameter. The default boot mode value for instances launched from AMIs that lack the boot mode parameter is UEFI on Graviton or legacy-bios on Intel and AMD instances.

Also read - AMD vs Intel

AWS Windows AMIs

AMIs for Windows configurations are made available publicly by Amazon Web Services. These AMIs can build and deploy applications quickly on Amazon EC2.

It is possible to install any edition of Microsoft SQL Server with Windows AMIs (SQL Enterprise Edition, SQL Server Standard, SQL Server Express, or SQL Server Web). Microsoft SQL Server can be run as a database server by launching an instance from a Windows AMI. A second alternative is to start an instance using any Windows AMI and then install the database software on the Instance.

Find a Windows AMI

AMIs must be selected before an instance can be launched. Consider the following criteria when choosing an AMI for the instances you intend to run:

  • The Region
  • The operating system
  • The architecture: 32-bit (i386) or 64-bit (x86_64)
  • The provider (for example, Amazon Web Services)
  • Additional software (for example, SQL Server)
     

You can find a windows AMI using the below services.

  • Find a Windows AMI topics
  • Find a Windows AMI using the Amazon EC2 console
  • Find an AMI using the AWS Tools for Windows PowerShell
  • Find an AMI using the AWS CLI
  • Find the latest Windows AMI using Systems Manager
  • Use a Systems Manager parameter to find an AMI

Shared AMIs

An AWS developer creates a shared AMI and shares it with other users. Shared AMIs make AWS easier to use for new users. On the other hand, Shared AMIs are not guaranteed to be safe or reliable and must be treated as any other foreign code.

Using the Amazon EC2 console, select the "AMIs" option from the navigation pane to find the following shared AMIs:

Private images: Private images contain all shared AMIs, which you can only use.

Public images: All public AMIs are contained in this directory.

AMIs can be created and shared with an AWS account, public or private. 

Paid AMIs

AS THE NAME SUGGESTS, an AMI purchased from another developer is a paid AMI. Creating a custom AMI and selling it on the AWS Marketplace, an online marketplace for paid custom AMIs is an option for AMI developers. The AMI owner determines the charges for paid AMIs. You can find a paid AMI from the Amazon EC2 console or AWS Marketplace.

AMI lifecycle

You can create your own AMIs by the following steps of the AMI lifecycle:

  1. Create an AMI
  2. Copy an AMI
  3. Store and restore an AMI using S3
  4. Deprecate an AMI
  5. Deregister your AMI
  6. Recover AMIs from the Recycle Bin
  7. Automate the EBS-backed AMI lifecycle

Source: mindmajix

Use encryption with EBS-backed AMIs

Confirm that encryption is enabled for EBS-backed AMIs. It is possible to launch unencrypted instances using AMIs with unencrypted data volumes. AMIs backed by Amazon EBS snapshots can use Amazon EBS encryption. AMIs can be created by attaching encrypted snapshots of both data and root volume. Full EBS encryption is supported during launching instances and copying images. In all regions supporting AWS KMS, encryption parameters are supported for these operations.

The identical AMIs are used to launch EC2 instances with encrypted EBS volumes as for some other cases. You can also encrypt some or all of the volumes when you launch an instance from an AMI backed by an unencrypted EBS snapshot.

Understand AMI billing information

When launching your instances, you can choose from a variety of Amazon Machine Images (AMIs), which support various operating systems and features. When establishing your Instance, you can research the associated operating system platform and billing information to understand how the AMI you choose affects the bottom line on your AWS bill. Before setting up an On-Demand instance, a Spot instance, or a Reserved instance, you must do this.

Here are how it works:

  1. AMI billing information fields
  2. Finding AMI billing and usage details
  3. Verify AMI charges on your bill

EC2 fleet

A new Amazon EC2 feature called the EC2 Fleet gives EC2 users more flexibility in provisioning capacity across different Amazon EC2 instance types, availability zones, and purchase models: On-Demand, Amazon EC2 Reserved Instances (RI), and Amazon EC2 Spot. You can now scale, perform, and reduce costs using EC2 instance types and purchase models with a single API call. 

By creating EC2 Fleet specifications, you will be able to define target capacity, EC2 instance types that will work for you, and how much of the fleet should be filled by On-Demand, RI, and Spot. As part of the scaling process, you can also indicate whether the number of cores and amount of memory on each Instance should be considered or if all instances should be treated equally. A combination of EC2 instances will then be launched based on these preferences to meet the target capacity. You can quickly provision capacity with the EC2 fleet using multiple instance types and purchase models in the AWS Management Console.

Security in Amazon EC2

AWS customers place a high priority on information security. AWS provided global computing, storage, networking, database infrastructure, and a shared responsibility model. It also offers higher-level services. By utilizing AWS as a foundation, you can design and architect an Information Security Management System (ISMS) using AWS features.

For AWS ISMS, you must understand the shared responsibility model, which requires AWS and clients to work together toward security objectives. Amazon Web Services (AWS) specifies that it manages the security of the following assets as part of its shared responsibility model for infrastructure services, like Amazon Elastic Compute Cloud (Amazon EC2), which includes: 

• Facilities

• Physical security of hardware

• Network infrastructure

• Virtualization infrastructure
 

As far as your ISMS asset definition is concerned, AWS owns these assets. Include these AWS controls in your ISMS. As the customer, you are responsible for securing the following assets:

• Amazon Machine Images (AMIs)

• Operating systems

• Applications

• Data in transit

• Data at rest

• Datastores

• Credentials

• Policies and configuration

Frequently Asked Questions

What are the benefits of EC2?

Here are some benefits of EC2:

  • Elastic Web-Scale Computing 
  • Highly flexible
  • Scalable
  • Reliable 
  • Secure 
  • Inexpensive

Is Amazon EC2 a virtual machine?

The Amazon Web Services (AWS) Elastic Compute Cloud (EC2) is a virtual server for running applications. In an EC2 instance, you can customize CPU, storage, and memory resources. The type of Instance you choose will depend on the resources you need.

What is the difference between ECS and EC2?

Cloud computing is a service offered by AWS Elastic Compute Cloud (EC2). The Amazon Elastic Container Service (ECS) provides container orchestration and is a scalable computing service. A quick explanation of ECS vs. EC2 is that Amazon ECS uses Amazon EC2 instances to use containers.

How are VMs and instances different?

A virtual machine uses emulated hardware to create a fully-contained object to provide services. Virtual machines are characterized by instances, which are differential copies. Instances are created from images. The images are the source virtual machines.

Conclusion

This blog shows what Amazon EC2 is and how to set up an EC2 instance step by step.

We hope that this blog has helped you enhance your knowledge about Amazon EC2 and if you would like to learn more, check out our articles on the link. Do upvote our blog to help other ninjas grow. 

Check out the Amazon Interview Experience to learn about Amazon’s hiring process.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problems, interview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Next article
Amazon Lightsail
Live masterclass