04
OctGrab Deal : Flat 20% off on live classes + 2 free self-paced courses! - SCHEDULE CALL
EC2 stands for Elastic Compute Cloud. It enables executing applications on customized cloud instances. So why do we need EC2? Local computer environments are constrained by the availability of hardware resources. Hence, applications can be run on configured ‘instance’ on EC2 cloud. Instance corresponds to a virtual server running on top of physical EC2 resources.EC2 instances come in several different flavors:
For example, instance types can be expressed as :
c4.large, c5.xlarge, r4.large, x1e.8xlarg, i3.large, g3s.xlarge, i3.metal.
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.
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.
Required files can be transferred to the ec2 instance using PuTTY Secure Copy client (PSCP) or WinSCP.
When an EC2 instance is launched, it can be associated with a security group.
AWS Solution Architect Training and Certification
The security group acts as a virtual firewall that controls the traffic to the instance/instance set. An AWS account automatically has a default security group created. A new EC2 instance is automatically associated with the default security group. The security group rules for the EC2 instance control the incoming traffic for an instance.
Amazon EBS volume is a block-level storage device that can be attached to a single EC2 instance.
AWS Solution Architect Training and Certification
EBS provides the following volume types:
EBS volume can be formatted with a filesystem and mounted as a block device.
AWS provides Elastic Volumes with which you can dynamically modify the size, performance, and type of your Amazon EBS volumes without detaching them.
RAID stands for Redundant Array of Independent Disks.
Data is split across multiple disks
Redundant data across multiple disks
Data is split across multiple disks together with a parity bit
Data is split across multiple disks together with two parity bits
It combines the advantages of RAID 0 and RAID 1
LogOn to the EC2 instance via mstsc and open the Disk Management utility.
Right-click on the volume and select the desired RAID option.
Define storage resources for the selected RAID option.
Right click on the instance name and choose ”Create Image” from the context menu.
The new AMI will appear in AWS Explorer under the AMIs section.
Instance store is a directly attached, block-device storage associated with an EC2 instance. EBS volumes ,on the other hand,behave like raw, unformatted block devices which can be mounted as devices on your instances. The instance store is suitable for temporary storage. Data stored in instance store volumes is not persistent through instance stops, terminations, or hardware failures. EBS volumes preserve their data across instance stops and terminations.
Load Balancing provides for efficient distribution of network/application traffic across multiple servers in a cluster. A load balancer accepts incoming traffic from clients and routes requests to its registered targets (e.g. EC2 instances) in one or more Availability Zones. AWS Elastic Load Balancing offers three types of load balancers:
The Amazon Elastic Load Balancing Service Level Agreement commitment is 99.99% availability for a load balancer.
AWS Solution Architect Training and Certification
Load Balancer periodically sends requests to its registered targets to test their status. These tests are called ”health checks”.The load balancer sends a health check request to each registered target every Health Check Interval Seconds seconds(default: 30 for instances), using the specified port, protocol, and ping path. If the health checks exceed Unhealthy Thres hold Count consecutive failures (default: 2), the load balancer marks the target as unhealthy. When the health checks exceed HealthyThres hold Count consecutive successes (default: 5), the load balancer puts the target back in service.
Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications. It records and retains metrics for a period of 15 months.
By default, Amazon EC2 sends metric data to CloudWatch in 5-minute periods. To send metric data for your instance to CloudWatch in 1-minute periods, you can enable detailed monitoring on the instance.
CloudWatch Metrics can be accessed using:
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:
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
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.
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.
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.
AWS
DevOps
Data Science
Hadoop
Salesforce
QA
Business Analyst
MS SQL Server
Python
Artificial Intelligence
Machine Learning
Tableau
Search Posts
Related Posts
What is AWS CLI? How to Install AWS CLI?
5.6k
What is AWS Data Pipeline? AWS Data Pipeline Tutorial Guide
113.4k
What is AWS CloudFormation: Concepts, Templates, and EC2 Use Case
1.8k
10 Ways To Fuel Your Career in Cloud Computing
2.5k
Grow your career with these Top 10 AWS Influencers/ Cloud Computing Leaders
2.5k
Receive Latest Materials and Offers on AWS Course
Interviews