Amazon EC2 (Elastic Compute Cloud)
Hello Readers, Here I am going to walk you through all the options available in AWS EC2 service which can be useful while working in a real environment.
It is a web service provided by Amazon Web Services (AWS) that offers resizable computing capacity in the cloud. EC2 allows users to rent virtual servers (known as instances) on which they can run their own applications.
Launch an instance :
This allows you to create virtual machines, or instances, that run on the AWS Cloud.
- Application and OS Images (Amazon Machine Image): An AMI is a template that contains the software configuration.
You can select an AMI provided by AWS, our user community, or the AWS Marketplace; or you can select one of your own AMIs.
You can find the difference Between AMI and Snapshot: Into my BLOG - Instance type: Instance types refer to different configurations of virtual servers (instances) that are optimized to fit various use cases and workloads.
- Key pair (login): You can use a key pair to securely connect to your instance.
- Network settings: Settings enable communication between your EC2 instances, other AWS services, and the internet, which contains the following paraments:
1. Virtual Private Cloud (VPC)
2. Subnet
3. Auto-assign public IP
4. Firewall (security groups): A security group is a set of firewall rules that control the traffic for your instance. Add rules to allow specific traffic to reach your instance.
We can set Inbound Security Group Rules as a firewall for the instance. - Storage (volumes): Amazon EBS provides block-level storage volumes that you can attach to EC2 instances.
These are the primary storage volumes that you attach to EC2 instances.
They are persistent and maintain their data even after the associated instance is stopped or terminated.
Note: Storage like EBS, EFS, FSx, etc. Except for S3 all are dependent on the availability zone (They must be into same zone).
6. Advanced details: Provides some additional features such as:
- IAM instance profile: Allows you to assign IAM roles to EC2 instances.
IAM instance profiles enable EC2 instances to securely access other AWS services and resources without the need for access keys or credentials stored on the instance itself. This enhances security by reducing the risk of exposing sensitive credentials. - Hostname type /DNS Hostname
- Instance auto-recovery/ Shutdown behavior/ Stop — Hibernate behavior/ Termination protection/ Stop protection.
- Detailed CloudWatch monitoring: Monitoring allows you to enable detailed monitoring for the instance. With detailed monitoring enabled, CloudWatch collects metrics at a higher frequency (1-minute intervals) compared to basic monitoring (5-minute intervals).
- Elastic GPU: Allow you to attach GPU resources to instances for graphics-intensive applications. These GPU resources can be dynamically added or removed from instances as needed.
- Purchasing option / Metadata / License
- User data : User data allows you to specify a script or commands to run when the instance starts.
- Elastic IP (IPv4): Elastic IP addresses are static IP addresses that can be associated with EC2 instances. You can specify an Elastic IP address to associate with the instance when it is launched. This is useful for instances that require a persistent public IP address.
Connecting to instance :
Once you Launch the Instance next step is how you will connect to it or work on it, so there are a few ways we can connect to the instance.
- SSH (Secure Shell): SSH is a secure network protocol that allows you to access and manage Linux-based EC2 instances remotely.
SSH client installed on your local machine: Such as OpenSSH on Linux/Mac or PuTTY on Windows.
The typical command to connect via SSH is: ssh -i /path/to/private_key.pem user@ec2_instance_public_ip
.
2. Remote Desktop Protocol (RDP): RDP is a protocol developed by Microsoft for remote desktop connections to Windows-based EC2 instances.
3. AWS Systems Manager Session Manager: AWS Systems Manager provides a managed service called Session Manager, which allows you to securely connect to EC2 instances without the need for SSH or RDP.
4. AWS Instance Connect: It allows you to connect to instances directly from the EC2 console or the AWS CLI without the need for SSH keys.
5. Third-Party Tools: There are various third-party tools and utilities available for connecting to EC2 instances, such as MobaXterm, Termius, and Bitvise SSH Client