Creating an Instance on AWS using Ubuntu - AWS Tutorial

Akinsooto Abidemi - Oct 26 - - Dev Community

To create an EC2 instance on AWS using an Ubuntu image, follow these steps:

Step 1: Log in to the AWS Management Console

  • Open the AWS Management Console.
  • Log in with your credentials.

Step 2: Navigate to EC2 Dashboard

  • In the top-left corner, click on Services.
  • Select EC2 under the Compute category or search for EC2.

Image description

Step 3: Launch an Instance
Click Launch Instance.
Enter a name for your instance (optional).

Image description
Or click on instances running and click on launch instance.

Image description

Image description

Step 4: Choose an Amazon Machine Image (AMI)

  • Under Application and OS Images (Amazon Machine Image), select Ubuntu.
  • Choose the version you need (e.g., Ubuntu Server 20.04 LTS).
  • Make sure it’s an x86 or ARM version depending on your needs.

Image description

Step 5: Select or Create a Key Pair
Choose an existing key pair if you have one, or create a new one.
If creating a new key pair, download the .pem file and keep it safe. This is the only time you can download it.

  • Click Next: Configure Instance Details.

Image description

Step 6: Configure Instance Details

  • You can leave most settings as default just like i did mine.
  • Ensure Auto-assign Public IP is enabled if you need to connect to the instance over the internet.
  • You can add tags or configure other settings if needed.
  • Click Next: Configure Security Group.

Step 7: Configure Security Group

  • Create a new security group or choose an existing one.
  • Add rules to allow specific traffic:
  • SSH: Port 22 (Source: Anywhere or your IP address)
  • Additional rules depending on what you plan to run (e.g., HTTP, HTTPS)

Image description

Step 8: Choose an Instance Type

  • Select the instance type (e.g., t2.micro for a free tier eligible, low-cost option).

Step 9: Add Storage
The default is 8 GB. You can increase it if necessary. I left mine as default.

Step 10: Review and Launch
Review the details of your instance.
Click Launch.

Image description

Image description

Image description

Step 11: Connect to Your Ubuntu Instance
After your instance is running, go to the Instances page on the EC2 dashboard.
You will see your Public IPv4 Address.
Then go to Visual studio code, click run terminal and follow the instructions below:
Using Gitbash in your Vscode, use this:
ssh -i /path/to/your-key.pem ubuntu@your-instance-public-ip

Replace /path/to/your-key.pem with the path to your key file and your-instance-public-ip with the public IP of your instance.
You can find your public IP address when you open the instance you created.

For mine it is ssh -i C:\Users\Abidemi\Downloads ubuntu@13.60.255.148 as shown in the image below:
After you run this command, you will see are you sure you want to continue connecting? type yes.

Image description

Image description

To install apache, type sudo apt install apache2 -y

Image description

sudo systemctl start apache2
sudo systemctl enable apache2

Then git clone your webapp using this command:
sudo git clone https://github.com/yourtechie/fruitables.git
then click enter.
When the cloning has been successfully done you can now type your Public ip address on your browser to access the your webapp.

Image description

Image description

You now have an Ubuntu EC2 instance running on AWS. Let me know if you need further assistance!

. . . . . . . . . .