How to Create an EC2 Instance on AWS
Amazon Elastic Compute Cloud (EC2) is one of AWS’s most popular services, allowing you to launch and manage virtual servers in the cloud. Whether you're hosting a website, running a database, or testing software, EC2 provides scalable, secure, and customizable computing capacity.
This guide walks you step by step through creating a basic EC2 instance using the AWS Management Console.
Prerequisites
- An AWS account (sign up at https://aws.amazon.com if you don’t have one).
- Basic familiarity with cloud concepts.
- (Optional) SSH key pair for secure remote access.
Step 1: Sign in to the AWS Management Console
- Go to https://console.aws.amazon.com.
- Sign in with your AWS credentials.
Step 2: Navigate to the EC2 Dashboard
- From the AWS Console, search for “EC2” in the search bar.
- Click EC2 to open the EC2 Dashboard.
Step 3: Launch an Instance
- Click Instances in the left-hand navigation pane.
- Click the Launch Instance button.
Step 4: Configure Instance Basics
On the “Launch an Instance” page:
- Name: Enter a name for your instance (e.g., “MyFirstInstance”).
- Application and OS Images (AMI): Choose an Amazon Machine Image (AMI). For beginners, the Amazon Linux 2023 AMI (Free Tier eligible) is a good choice.
- Instance Type: Choose the instance type (e.g.,
t2.micro
for Free Tier eligibility).
Step 5: Create or Choose a Key Pair
- In Key pair (login), choose an existing key pair or create a new one.
- If creating a new one:
- Click Create new key pair.
- Enter a name, choose the format (e.g.,
.pem
for Linux/Unix), and download it securely.
Important: Keep this file safe. You’ll need it to SSH into your instance.
Step 6: Configure Network Settings
- By default, AWS will select a VPC and subnet for you.
- Under Firewall (security groups):
- Either create a new security group or select an existing one.
- For SSH access:
- Add a rule: Type = SSH, Port = 22, Source = Anywhere (0.0.0.0/0) or My IP (more secure).
Warning: Opening SSH to “Anywhere” is less secure. Restrict to your IP when possible.
Step 7: Add Storage
- The default root volume is usually sufficient (e.g., 8 GiB gp2).
- You can increase the size or add additional volumes if needed.
Step 8: Review and Launch
- Review your instance configuration.
- Click Launch Instance.
Step 9: View and Connect to Your Instance
- After launching, click View Instances.
- Wait for the Instance State to show running.
- Select the instance and note its Public IPv4 address.
Step 10: Connect to Your Instance (SSH)
From your terminal:
bash
ssh -i /path/to/your-key.pem ec2-user@your-public-ip
## Example
ssh -i my-key.pem ec2-user@54.123.45.67
chmod 400 /path/to/your-key.pem
Tidak ada komentar:
Posting Komentar