Creating an EC2 instance

Since we have already done the groundwork in the previous steps. Now, it is just a matter of creating an EC2 instance. From the EC2 dashboard, click on Instances in the navigation pane and then on Launch instance. This will start a process of provisioning an EC2 instance.

  1. The next step is to choose an EC2 instance, and this is done by choosing the right Amazon Machine Image (AMI) as per our requirements. Select the Ubuntu Server 16.04 LTS (HVM) SSD Volume Type AMI:
  1. After selecting an AMI image, the next option is to choose an instance type. The instance is the virtual server that will run our application. Select the t2.micro instance, which is included in the free-tier for a period of 1 year from the date you created your AWS account. Click on the Next: Configure Instance Details button:
  1. Next, we configure the EC2 instance. There are several options available at each step, and we need to make the most appropriate choices for our purposes:
    1. Number of instances: This allows launching of multiple AMI instances. By default, it is set to 1 (no need to change that). You can always launch multiple instances via the EC2 dashboard.
    2. Purchasing option: Since we are using the free tier, we can ignore this. The idea of purchasing option relates to excess capacity for an instance type in an AWS region made available to use at a lower price point.
    3. Network: By default, all EC2 instances are launched in VPC. We use the default VPC.
    4. Subnet: By default, each subnet is associated with an availability zone within a region. Select the No preference (default subnet in any AZ).
    5. Auto assign Public IP: When an EC2 instance starts, it can request a public IP address from Amazon’s pool of public IP addresses (so that it can be a part of the public internet). This public IP address will be available as long as the EC2 instance is on. Each time the EC2 instance starts, it will get a public IP address from the Amazon’s pool of public IP address. The public IP is not persistent. If we want the public IP address to be persistent across restarts, then we have to use Elastic IP, which we will set up in a later step. Set this to Disable for now.
    6. IAM role: Select the role ec2Instances created earlier.
    7. Shutdown behavior: An instance can be either stopped or terminated on shutdown. Select Stop.
    8. Enable termination protection: It is a mean to disable the terminate option for the EC2 instance in the EC2 dashboard. Select this option.
    1. Monitoring (Enable): This is to enable collection of metrics and analysis via AWS CloudWatch. Logging of basic metrics are free (with some restrictions). Refer to https://aws.amazon.com/cloudwatch/pricing/ for what you get free and what you have to pay for. For our purposes, you do not need to select this option.
    2. Tenancy: Shared tenancy uses an over-subscription model to rent the hardware among the customers. This makes the performance of the EC2 instance unpredictable at times. To overcome this problem, Amazon also provides a dedicated tenancy option, which costs more but reserves the instance exclusively for your use. Select the Shared tenancy option from the dropdown.
    3. Advanced Details: This option is used to pass user data or scripts to the EC2 instance. Right now, we do not pass any user data or scripts to the EC2 instance. So, no changes are needed.
    4. Click on Next: Add Storage to provision persistent storage.
  1. Next, we configure the persistent storage also known as Elastic Block Storage (EBS). EBS does not go away when the system reboots or crashes. It is the hard disk for your EC2 instance. Up to 30 GB of disk is available in the free tier, which is sufficient for most applications. Select General Purpose SSD (GP2) from Volume Type column. The data access speed of the disk is proportional to the size of the disk. It is defined in terms of IOPS which stands for input output operations per second. One IOP is defined as a block of 256 KB data written per second. Click on Next: Add Tags:
  1. Next, we tag the EC2 instance. Tags do not have any semantic value and are treated purely as strings in a key-value form. You can work using the tags with the AWS management console, EC2 API and EC2 command-line interface tools. Click on Next: Configure Security Group:
  1. Next, we assign the security group sq-EC2WebSecurityGroup we defined earlier in step 1. Click on the Select an existing security group radio button to view all the available predefined security groups. Select the sq-EC2WebSecurityGroup from the list. Click on Review and Launch:
  1. Next, we can review the options we have selected, and modify them, if required. Click on Launch to launch the instance.
  2. Upon launch, the EC2 instance will prompt you to select the public/private key pair that was created earlier. Select the ec2AccessKey from the drop-down list box. Click on Launch Instances to launch the EC2 instance. The key pair once assigned to instance cannot be changed. Make sure you store your private key, securely.
  1. Your EC2 instance will take some time to start.
  1. After the EC2 instance is up and running, you should see it listed in the console. You can review the details of the instance to ensure that it is as per what you configured:

You cannot access the instance as it does not have a public IP associated with it yet. The EC2 instance is assigned an IP address from the VPC subnet, in this case, it is 172.31.18.70. This EC2 instance can be used only for communication between the instances in your VPC.

Next, we create an elastic IP and assign it to the EC2 instance so that it can be accessed via the public internet. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.233.44