01
NovDiwali Deal : Flat 20% off + 2 free self-paced courses + Free Ebook + $200 Voucher - SCHEDULE CALL
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.
(A1,T3,T2,M5, M4,M3)
(C5, C4, C3)
(X1,Z1,R5,R4,R3)
(P3, P2, G3, F1)
(I3)
(D2)
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.
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.
Creating an AMI:
Instance storage vs. EBS volumes:
Load balancing:
CloudWatch monitoring:
Accessing CloudWatch metrics:
This rewrite clarifies technical terms, simplifies explanations, and removes unnecessary steps (like using mstsc for EC2 instances).
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.
FaceBook Twitter LinkedIn Pinterest EmailA 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.
Cyber Security
QA
Salesforce
Business Analyst
MS SQL Server
Data Science
DevOps
Hadoop
Python
Artificial Intelligence
Machine Learning
Tableau
Search Posts
Related Posts
Receive Latest Materials and Offers on AWS Course
Interviews