In this tutorial, we are going to learn how to setup EC2 resources by choosing Amazon Machine Image (AMI), add storage, configure security groups, and create PEM key to access your instance using SSH.

Prerequisites

You need an Amazon Web Services Account.

Choose Amazon Machine Image(AMI)

  • You need to AWS console and navigate to Services -> EC2.
alt text
  • Then Click on Instances on the left sidebar.

  • After that click on Launch instance.

Then you will redirect to a page where you can choose any AMI according to your requirments but in this tutorial I am using Ubuntu server 18.04 image.

alt text

Choose Instance type

Here you can choose your desired machine type. In this tutorial I am using t2.micro type instance.
alt text

Then click on Configure Instance Details

Configure Instance

Here you can choose how your instance should run as dedicated or as shared. But for now we leave all settings to be as default. alt text

Then click on Add Storage

Add Storage

alt text

In this tutorial we leave this with the default settings.

Then click on Add Tags

Add Tags

Tags are useful to identify the Instance, here we will assign a name to our instance.

Click Add Tag, then enterName as the Key & Test-EC2 as value. You can any value according to your preference.

alt text

Click Configure Security Group

Configure Security Group

This is an important setup where you can allow connections to your instance by opening certain ports. alt text

By default SSH port is enabled.

  • If you need your website to be viewed in the internet then you need add rules to allow connections to HTTP and HTTPS.

  • Click Add rule.

  • From the type select HTTP.

  • Again click Add rule.

  • From the type select HTTPS.

If you need any additional ports opened you can add rules for those ports also.

Click Review and Launch.

Review the Instance details

In this section you can review all the options you have chosen in the steps before. Once you have reviewed them you can click launch.

Create PEM key and launch Instance

alt text
  • Now you will be prompted to assign a key pair to access your instance.

  • Select create a new key pair.

  • Enter a name to your key.

  • Click Download Key Pair.

Important: Save the key pair, if you miss this key you wont be able to access your instance using SSH.

  • Click Launch instances.

That’s all. Now your instances will be launched with Ubuntu 18.04 and will all the configurations you made.