How to Create EC2 Instance :
o create an EC2 Instance :
you need to choose an AMI ((Amazon Machine Image) an Operating system for your instance).
Then, Define the Instance Size ( Which kind of CPU and how much RAM).
Then, how much Storage (pretty self explanatory) you want.
then Security Groups ( Like almost a firewall, so from which ports can people connect with or which ports can data leave from the EC2 Instance).
You can also define the EC2 user data ( a bootstrap script which launches at the first start of an instance).
There are ways to connect to your EC2 instance directly, such as SSH ( Secure Shell ) so you can connect to your EC2 instance with SSH in a terminal from, you can also connect with SSH client like PuTTY. I prefer the EC2 Instance connect though as it's just browser-based, simple and just a good feature by AWS.
EC2 Instance Roles are just defined permissions attached to an EC2 instance to allow it to do certain things, so then you can use AWS commands in the CLI to perform AWS functions.
EC2 Purchasing Options :
There's a few instance purchasing options available for EC2 instances :
On-demand Instances - This is when you can't predict how long/short the job is going to be, so you just get a pay-as-you-go option. Billing for this is as follows : -> For Linux = billed every second, after the first minute ( yes, this is a bit complicated) -> All other operating systems = billed per hour.
Reserved Instances - This is for steady usage apps ( like databases) which are long-term ( a minimum of 1 year). this has up to 75% discount compared to on-demand. You can buy it for 1 year to 3 years and obviously, 33 years RI has a much higher discount than 1 year RI. Also, you can pay all upfront, partially upfront and no upfront and all upfront has much higher discount than no upfront. there are also 2 other types of RIs: -> Convertible RIs ( you can change the type of instance type, e.g. t2.micro to c5.large; these have up to a 54% discount). -> Scheduled RIs ( launch within the time window you need them but you still need to reserve it!).
Spot Instances - this is for work that is alright if it fails, so things like image processing, batch jobs and any distributed workloads. these have 90% discount compared to on-demand! But that's because they can be lost at any point of time if someone else pays higher for it ( kind of like bidding).
Dedicated Hosts - This is for companies with strict compliance requirements it's a whole physical; server dedicated just to you! And you need to be pretty rich to have this aka it is very expensive. Allocated for 3 years so they need to be committed to. Access to the underlying hardware.
Dedicated Instances - Basically dedicated hosts but you don't have access to the underlying hardware. Pay by the hour.
EC2 Instances - Summary
EC2 Instance : AMI (OS) + Instance Size ( CPU + RAM ) + Storage + Security groups + EC2 user data
Security Groups : Firewall attached to the EC2 instance.
EC2 User Data : Script launched at the first start of an instance (bootstrap)
SSH : Start a terminal into our EC2 instances ( port 22)
EC2 Instance Role : link to IAM roles
Purchasing Options : On-Demand, Spot, Reserved ( Standard + Convertible + Scheduled), Dedicated Host, Dedicated Instance.
EC2 Storages :
EBS - Elastic Block Store Volumes :
Network Drive which you can just attach to your EC2 instance -> So almost like plugging in a USB flash drive into your computer where the USB flash drive is the EBS volume and your computer is the EC2 instance and also, because it's one USB stick, you can only plug it into one computer at a time, so EBS volumes can only be mounted to one EC2 instance at a time.
Tied to only one availability zone and can only be attached to instances in the same availability zone.
They aren't actually a physical drive, they are a "network drive" so there might be some latency to communicate between the instance and the volumes because it is across a network.
EBS - Elastic Block Store Snapshots :
=> Basically, it's a backup of your EBS volume. Simple as that. This is especially useful for using the same EBS volume across an availability zone or region because EBS volumes are only for one AZ.
EC2 Instance Store :
Basically a godlike version of EBS volumes ( so much faster and higher I/O performance) but they lose everything once the EC2 instance is stopped.
EFS - Elastic File System :
It's just a network file system ( NFS ) which can be mounted to hundreds of different EC2 instances. but the instances can only be Linux instances and they can be all across a region, so different Availability Zones within the same region. => More expensive than EBS.
EFS-IA - Elastic File system Infrequent Accessed :
Is a storage class that is cost-optimized for files not accessed every day, EFS will automatically move your files to EFS-IA based on the last time they were accessed. You can enable it with a Lifecycle Policy. For example move files that are not accessed for 60 days to EFS-IA - Transparent to the application accessing EFS.
Amazon FSx For windows File Server :
A fully managed, highly reliable and scalable Windows native shared file system.
Built on Windows File Server.
Support SMB protocol & Windows NTFS
Integrated with Microsoft Active Directory for user security.
Can be accessed from AWS or your on-premise infrastructure.
Amazon FSx for luster
A fully managed, high-performance, scalable file storage for High Performance Computing ( HPC )
The name Luster ( Linux ) and (cluster)
Allows you to run a lot of use cases (e.g. "Machine Learning, Analytics, Video processing, financial, modeling.."
Scales up to 100s GB/s, million of IOPS, sub-ms latencies
EC2 Instance Storage - Summary
EBS volumes : -> Network Drives attached to one EC2 instance at a time. -> Mapped to an AZ -> Can use EBS snapshots for backups / transferring EBS volumes across AZ
AMI : create ready-to-use EC2 instances with out customizations.
EC2 Image builder : automatically build, test and distribute AMIs.
EC2 instance Store : -> High-Performance hardware disk attached to out EC2 instance -> Lost if our instance stopped/terminated.
EFS : network file system, can be attached to 100s of instances in a region.
EFS-IA : cost optimized storage class for infrequent accessed files.
FSx for Windows : Network file system for windows servers.
FSx for Luster : High-Performance computing Linux file system.
Last updated