EC2
EC2
EC2 is a service in AWS, allows you to create and manage EC2 instances. EC2 instances are basically virtual machine, highly recommend you to read (https://www.learn-aws.com/2024/11/server-virtualization.html). So long story short, EC2 allows you create/manage EC2 instances based on your resource needs.
How EC2 instances works ?
There are powerfull servers on AWS datacenters and hypervisor software used to manage those EC2 instances (virtual machines) on these servers. A lot of variying CPU,RAM,networking combination of EC2 options available.
There are 3 types of IP addresses for EC2 instances:
Public:
- You are not charged for public IP assignment
- Lost when instance is stopped (When you stop and start instance new public address will be assigned)
- Associated with private IP address
- Cannot be moved between instances
Private:
- Retained when instance is stopped (Start and stop instance same private address will be assigned)
- Used in association with public address
Elastic:
- You are charged for elastic IP address assignment
- Static public address (doesn't change)
- Associated with private IP address on the instance
- Can be moved between EC2 instances and Elastic network adapters.
EC2 instance types
nano,micro,large, xlarge etc.- Indicates how big,powerfull (vCPU,RAM etc.) EC2 instance really is.
t,c,r,d,g - These letters indicate purpose of instance. For which purpose our instance will be suitable.
For example :
t2.micro - General purpose (t), 2nd series (2), small server (micro - 1GB RAM, 1 vCPU).
g2.2xlarge - GPU instance (g), 2nd series (2), extra large server (2xlarge - 8vCPU, 15GB RAM)
More information is here : https://docs.aws.amazon.com/ec2/latest/instancetypes/instance-type-names.html
What is AMI ?
AMI - Amazon Machine Image,machine images are like templates that are configured with an operating system and other software that determine the user's operating environment.
Why is it important ?
For example let's suppose you want to create 20 EC2 instance for project but you want to be sure all of the instaces have same software, updated OS, same version of specific library and sends request to server right after initialization stage. That is why it is important it's handy tool, also widely used. By the way you can create your own custom AMI or use already available ones.
Let's create EC2 instance and look at AMI's and create one our own.
- Select EC2 from main dashboard by typing "EC2" to the searchbar
- Let the service create security group from scratch. We can create security group and attach policies later on. And use it for other instances. But let's keep everything simple. To connect instance we need ssh protocol's port open to anywhere. Otherwise it wouldn't be possible to connect unless 0.0.0.0/0 allow security rule added.
- Let's connect using SSH client command is like below but add your own public IP address or public IP's DNS record like I did. And you will probably face with error like below. Reason for that is quite simple for the security reason SSH wants your private key only accessible by the root (admin) users. That is why we must change the permission of the private-key file.
Comments
Post a Comment