Launch EC2 Instance Introduction:
Amazon EC2 (Elastic Compute Cloud) is a fundamental cloud computing service and represents virtual cloud computers with availability. To Launch an EC2 Instance.
- Start an instance
- Create a key pair
- Configure a security group
- To connect to the instance we will use SSH
This leads to the fact that you can work in a cloud computing environment with maximal protection.
Launch EC2 Instance Objective:
Launch an EC2 Instance With the help of Git Bash launch an instance of the EC2, create a key pair, set up a security group that allows all traffic, connect to the instance, and shut it down at the end.
Launch EC2 Instance Prerequisites:
- AWS account.
- There is an install of Git Bash on your laptop.
- familiar with the AWS EC2 concept.
ALSO READ:
- Automating Linux monitor memory usage script
- How to install Linux Server Monitoring tool Nagios XI and NCPA
- How to Automate User Switch in Shell Scripts with Nopasswd Sudoers
Steps to Launch an EC2 Instance
1. Create a Key Pair Using Git Bash
- Open Git Bash on your laptop.
Run the following command to generate a new key pair:
ssh-keygen -f krishna_aws
- Copy the content of the public key file:
- Cat ec2-keypair.pub
- Log in to the AWS Management Console
- Navigate to EC2 Dashboard > Key Pairs > Create Key Pair
- Choose Import Key Pair, provide a name, and paste the copied public key.
2. Configure a Security Group
- In the EC2 Dashboard, go to Security Groups > Create Security Group.
- Provide a name and description.
- Under Inbound Rules, add the following:
- Type: All Traffic
- Protocol: All
- Port Range: 0-65535
- Source: 0.0.0.0/0 (for all IPs)
Note: Allowing all traffic is not recommended for production environments.
Save the security group.
3. Launch an EC2 Instance
- Navigate to Instances > Launch Instances.
- Configure the following:
- Name: Provide a name for the instance.
- AMI: Select an Amazon Machine Image (e.g., Amazon Linux 2).
- Instance Type: Choose a type (e.g., t2.micro for free tier).
- Key Pair: Select the key pair created earlier.
- Security Group: Select the security group created earlier.
- Click Launch Instance
- Wait for the instance to initialize.
4. Connect to the EC2 Instance
- Copy the public IP address of the instance.
Open Git Bash and run:
ssh -i krishna_aws ec2-user@44.202.92.44
- Replace <PUBLIC_IP> with the instance’s public IP.
- You will be connected to the EC2 instance.
5. Shutdown and Delete the EC2 Instance
To shutdown the instance:
sudo shutdown -h now
- In the AWS Management Console, navigate to Instances.
- Select the instance and click Instance State > Terminate Instance.
- Confirm the termination.
Now we can successfully Launch an EC2 Instance : Create a Key Pair and Configure Security Group
Thank You