Grab Deal : Flat 30% off on live classes + 2 free self-paced courses! - SCHEDULE CALL

- AWS Blogs -

EC2 in AWS - The Backbone of AWS



What is EC2 in AWS?

EC2 (Elastic Compute Cloud) in AWS is a service for renting virtual servers in the cloud. Traditional computers limit what you can achieve due to their fixed hardware. Amazon's Elastic Compute Cloud (EC2) solves this by providing virtual servers called instances. These instances run on Amazon's cloud infrastructure, giving you access to a wide range of computing power, memory, storage, and other resources.

Think of EC2 as a giant pool of computing power you can tap into on-demand.

EC2 offers a variety of instance types, each suited for different needs. These types are identified by codes like c4.large or i3.metal. Choosing the right type ensures your instance has the resources required to run your applications smoothly.

EC2 instances can be created using the AWS management console.

  • General Purpose – (A1,T3,T2,M5, M4,M3)
  • Computer Optimized – (C5, C4, C3)
  • Memory Optimized – (X1,Z1,R5,R4,R3)
  • Accelerated Computing (P3, P2, G3, F1)
  • Storage optimized-(I3)
  • Dense-storage Instances – (D2)

Instances are further classified as:

  • Large
  • Xlarge
  • 2xlarge
  • 4xlarge
  • 8xlarge

AWS EC2 1

AWS EC2 2

AWS EC2 3

AWS EC2 4

Once a new EC2 instance has been created, we can connect to the instance using Putty. We can start the Putty application and provide the configuration details for connecting to the instance.

AWS EC2 4

In the SSH section of the configuration, provide the ppk file for the key pair.

The tool puttygen can be used to convert pem keys to ppk format.

AWS EC2 5

Required files can be transferred to the ec2 instance using PuTTY Secure Copy client (PSCP) or WinSCP.

AWS EC2 6

AWS EC2 7

When an EC2 instance is launched, it can be associated with a security group.

Security Groups: Controlling Traffic Flow

Imagine a security group as a virtual firewall for your Amazon EC2 instances. It acts like a gatekeeper, deciding which incoming and outgoing traffic is allowed. By default, every AWS account has a basic security group, and when you launch a new EC2 instance, it's automatically linked to this default group. You can create custom security groups with specific rules to control the flow of traffic to your instances. These rules define what type of traffic (TCP, UDP, etc.) can enter or leave your instance on a particular port. This allows you to restrict access to your instances, enhancing security by only permitting authorized traffic.

EBS Volumes: Persistent Block Storage

Think of EBS volumes as digital hard drives for your EC2 instances. They provide persistent block-level storage, meaning the data remains on the volume even when you stop or restart your instance. This is unlike instance store volumes, which are temporary and lose data when the instance is stopped. EBS volumes offer various storage options depending on your needs, such as high performance for demanding applications or cost-effective options for data archives. You can format EBS volumes with file systems and mount them on your instances for data storage and retrieval.

Here's a key advantage: EBS volumes are elastic. You can dynamically modify their size, performance characteristics, or even switch between storage types on the fly, without having to detach them from your instance. This provides flexibility to scale your storage up or down as needed.

RAID Configurations

  • Striped data (RAID 0): Data is spread across multiple disks for improved performance (faster read/write). However, a single disk failure causes complete data loss.
  • Mirrored data (RAID 1): Data is duplicated across multiple disks for redundancy. Even if one disk fails, your data is safe on the other mirror. This comes at the cost of usable storage space.
  • Parity RAID (RAID 5, 6): Data is striped with additional parity information stored across the disks. This allows for data reconstruction in case of a single disk failure. RAID 5 uses one parity disk, while RAID 6 uses two, offering increased fault tolerance but with a performance penalty.

Creating an AMI:

  • An AMI (Amazon Machine Image) is a template for launching EC2 instances.
  • You can create an AMI from a running EC2 instance.
  • Right-click the instance and choose "Create Image" to capture its configuration as an AMI.

Instance storage vs. EBS volumes:

  • Instance storage: Temporary storage directly attached to an EC2 instance. Data is lost when the instance stops or terminates. Ideal for temporary workloads.
  • EBS volumes: Persistent block storage volumes that are independent of the EC2 instance lifecycle. Data remains intact even when the instance stops or terminates. Suitable for critical data.

Load balancing:

  • Distributes network traffic across multiple EC2 instances for scalability and high availability.
  • A load balancer acts as a traffic director, routing requests to healthy instances within a cluster.
  • AWS offers different load balancers for various needs.

CloudWatch monitoring:

  • Monitors your AWS resources and applications.
  • Records and stores metrics for 15 months by default.
  • You can configure detailed monitoring for more frequent metric collection (1-minute intervals).

Accessing CloudWatch metrics:

  • CloudWatch provides a dedicated console for viewing and analyzing metrics.

This rewrite clarifies technical terms, simplifies explanations, and removes unnecessary steps (like using mstsc for EC2 instances).

AWS EC2 instances can be accessed using AWS CLI.

For example, For sisplaying list of EC2 commands:

aws ec2 help

For launching a new instance:

aws ec2 run-instances --image-id --count 1 --instance-type t1.micro --key-name --security-groups

Listing instances:

aws ec2 describe-instances --filters "Name=instance-type,Values=t1.micro“

Block-device-mapping parameter can be used to specify additional Amazon EBS volumes or instance store volumes to attach to an instance when it's launched.

--block-device-mappings "[{\"DeviceName\":\"/dev/sdf\",\"Ebs\":{\"VolumeSize\":10,\"DeleteOnTermination\":false}}]"

Adding a tag to an instance:

aws ec2 create-tags --resources --tags Key=Name,Value=MyInstance

Terminate an ec2 instance:

aws ec2 terminate-instances --instance-ids

Keypair management:

aws ec2 create-key-pair …

aws ec2 describe-key-pairs …

aws ec2 delete-key-pair …

For associating Identity and Access Management Roles with EC2 instance, we use the following steps:

Screenshot of choosing Attach/Replace IAM role

Screenshot of choosing the IAM role

Screenshot showing EC2Role1 as the IAM role

Features of AWS S3 can be accessed using AWS CLI.

Displaying list of S3 commands:

aws s3 help

Creating a new S3 bucket:

aws s3 mb

Listing S3 buckets:

aws s3 ls

2019-12-11 15:02:20 my-bucket

2019-12-14 11:54:33 test-bucket

Deleting a bucket:

aws s3 rb

Copy local file to S3 bucket:

aws s3 cp file.txt s3://my-bucket/

Synchronize a local directory with a S3 bucket:

aws s3 sync . s3://my-bucket/path

Move content from S3 bucket to local directory:

aws s3 mv s3://my-bucket/path ./Temp

List the contents of the bucket:

aws s3 ls s3://my-bucket

Delete the contents of the bucket:

aws s3 rm s3://my-bucket/path

In order to determine the region where the bucket resides we can use the command aws s3api get-bucket-location.

For example:

aws s3api get-bucket-location --bucket test-bucket

This generates output of the following format:

{

    "LocationConstraint": "us-west-2"

}

Bootstrap scripts are used to perform common automated configuration tasks after the instance starts. 

Bootstrap script can be configured using CLI or from the console.

CLI:

--bootstrap-actions Path=s3://mybucket/filename

The bootstrap scripts are contained in the user data metadata of the EC2 instance.

Instance metadata is data about your instance that you can use to configure or manage the running instance. Instance metadata is divided into categories. The complete list of categories can be referenced at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html 

Instance metadata can be retrieved using the link local address 169.254.169.254 from within the EC2 instance.

For example:

TOKEN=`curl -X PUT "http://169.254.169.254/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/network/interfaces/macs/02:29:96:8f:6a:2d/subnet-id subnet-be9b61d7 (Subnet Id for the instance)

Auto Scaling group : a collection of EC2 instances that are a logical grouping for the purposes of automatic scaling and management.

Launch configuration : an instance configuration template that an Auto Scaling group uses to launch EC2 instances.

Launch Configuration includes 

Placement groups are used to influence the placement of a group of interdependent instances to meet the needs of your workload.

Placement groups can make use of the following strategies:

A placement group can also be created using CLI with the command:

   aws ec2 create-placement-group

Amazon EFS enables us to create file systems that are accessible to EC2 instances via a file system interface.

File Systems can be accessed using the NFS v4 protocol.

Multiple EC2 instances can access an EFS file system simultaneously.

Amazon EFS o?ers two storage classes:

Amazon EFS can be created using the console or CLI.

AWS Lambda lets you run code without provisioning or managing servers. There is no charge when code is not running. This enables serverless computing ( server management is taken care of by AWS).

AWS Solution Architect Training and Certification

  • Detailed Coverage
  • Best-in-class Content
  • Prepared by Industry leaders
  • Latest Technology Covered

Lambda supports Java, Go, PowerShell, Node.js, C#, Python, and Ruby code, and also provides a Runtime API which allows you to use any additional programming languages for your functions. Lambda stores code in Amazon S3 and encrypts it at rest. 

EC2 can be used to build a serverless webpage.

Conclusion

To summarize, EC2 provides scalable computing instances on the cloud. Amazon Machine Images(AMIs) are preconfigured templates for EC2 instances.EC2 instances come in varied instance types based on size and configuration.EC2 instances can make use of instance stores or EBS volume stores for data.EC2 instances can be created, administered and terminated using the console as well as the command line interface.

fbicons FaceBook twitterTwitter lingedinLinkedIn pinterest Pinterest emailEmail

     Logo

    JanBask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


  • fb-15
  • twitter-15
  • linkedin-15

Comments

Trending Courses

Cyber Security Course

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security Course

Upcoming Class

16 days 05 Jul 2024

QA Course

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA Course

Upcoming Class

8 days 27 Jun 2024

Salesforce Course

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce Course

Upcoming Class

7 days 26 Jun 2024

Business Analyst Course

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst Course

Upcoming Class

9 days 28 Jun 2024

MS SQL Server Course

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server Course

Upcoming Class

9 days 28 Jun 2024

Data Science Course

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science Course

Upcoming Class

2 days 21 Jun 2024

DevOps Course

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps Course

Upcoming Class

5 days 24 Jun 2024

Hadoop Course

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop Course

Upcoming Class

2 days 21 Jun 2024

Python Course

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python Course

Upcoming Class

17 days 06 Jul 2024

Artificial Intelligence Course

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence Course

Upcoming Class

10 days 29 Jun 2024

Machine Learning Course

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning Course

Upcoming Class

23 days 12 Jul 2024

 Tableau Course

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau Course

Upcoming Class

2 days 21 Jun 2024

Search Posts

Reset

Receive Latest Materials and Offers on AWS Course

Interviews