Creating an EC2 instance with Amazon Machine Image(AMI)

Amazon Elastic Compute Cloud (EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. EC2 allows you to launch as many or as few virtual servers as you need, configure security and networking, and manage storage.

An Amazon Machine Image (AMI) is a pre-configured virtual machine image that is used to create EC2 instances. AMIs contain information on operating systems, application servers, and applications that are supported on the EC2 platform.

In this tutorial, we will guide you through creating an EC2 instance with Amazon Machine Image.

Prerequisites

  • An AWS account
  • A key pair in the region you are using
  • A VPC and security group with inbound rules allowing SSH access
  • Basic familiarity with the AWS console

Step 1: Choosing an AMI

The first step in creating an EC2 instance is to select an Amazon Machine Image. We will select an Ubuntu 20.04 LTS AMI for this tutorial.

  1. Log in to the AWS Management Console and navigate to the EC2 dashboard.
  2. Click on “Launch Instance” at the top of the page.
  3. On the “Choose an Amazon Machine Image (AMI)” page, search for “Ubuntu 20.04 LTS” in the search bar.
  4. Choose the AMI that best suits your needs. We will choose the “Ubuntu Server 20.04 LTS (HVM), SSD Volume Type” AMI.
  5. Click “Select” to proceed with the chosen AMI.

Step 2: Choosing an Instance Type

The next step is to choose the type of instance you want to launch. The instance type determines the CPU, memory, storage capacity, and network performance characteristics of your instance.

  1. On the “Choose an Instance Type” page, select the instance type you want to launch. We will choose the “t2.micro” instance type for this tutorial.
  2. Click “Next: Configure Instance Details”

Step 3: Configuring Instance Details

The “Configure Instance Details” step allows you to select details about your instance, such as the number of instances to launch, the VPC and subnet, and the IAM role.

  1. Select the number of instances you want to launch. We will launch one instance for this tutorial.
  2. Select the VPC and subnet you want to use. These should be pre-configured before launching an instance.
  3. Select an IAM role for your instance, if applicable.
  4. Select “Enable termination protection” to prevent accidental termination of the instance.
  5. Click “Next: Add Storage”

Step 4: Adding Storage

The storage configuration step allows you to add additional storage volumes to your instance.

  1. Modify the size of the root volume, if needed. The default is 8GB, but we will change it to 30GB.
  2. Add additional EBS volumes if needed.
  3. Click “Next: Add Tags”

Step 5: Adding Tags

The “Add Tags” step allows you to add metadata to your instances, such as name, environment, or application.

  1. Click “Add Tag”
  2. Enter a name and value for your tag. For example, “Name” and “MyInstance”
  3. Click “Next: Configure Security Group”

Step 6: Configuring Security Group

The “Configure Security Group” step allows you to specify the security group for your instance.

  1. Select “Create a new security group” and give it a name and description.
  2. Add inbound rules allowing SSH access to your security group. For example, you can allow SSH access from anywhere by adding a rule with source “0.0.0.0/0” and port 22.
  3. Click “Review and Launch”

Step 7: Reviewing and Launching

The final step is to review your instance details and launch the instance.

  1. Verify that your instance details are correct.
  2. Click “Launch”.
  3. Select the key pair that you created in the prerequisites and click “Launch Instances”.

Your instance is now being launched. You can view its status on the EC2 dashboard. Once it is running, you can connect to it using SSH.

Conclusion

In this tutorial, we have shown you how to create an EC2 instance with Amazon Machine Image. First, we selected an Ubuntu 20.04 LTS AMI. Then, we chose the instance type, configured instance details, added storage, tags, and configured a security group. Finally, we reviewed and launched the instance.

By following these steps, you should now have a basic understanding of how to create an EC2 instance from an AMI. You can now go on to learn about more advanced features of EC2, such as scaling, load balancing, and auto-scaling.

Related Post