-In this demo, we will learn how to provision a Linux EC2-instance
using the AWS Management Console.
From the management console, to get to the EC to service,
click on the Services tab on the top left.
The EC2 service is located under the service group for Compute.
Another way to locate the service
is to make use of the service search bar from the dashboard.
We can also launch it by clicking on the Launch a virtual machine link
just under the Search bar.
We are now inside the EC2 console.
Please note that we are currently in the central region,
which is Canada,
and this is where we will be deploying this instance.
To create an EC2 instance,
click on the Launch instance button.
This will open up the launch wizard.
The first thing to do is to select an AMI,
which is Amazon machine image.
We are going to deploy a web server on Ubuntu,
so select the AMI for Ubuntu 20.04.
As you can see, this AMI is free tier eligible.
Next, we have to select the instance type,
so let's use t2 micro.
In the next step, we can configure the instance.
We will leave most of these to the default values.
For the network, we will make use of the default VPC,
which is automatically created for this region.
Think of VPC as an isolated private network
within the AWS infrastructure where we can deploy services.
Within this VPC, we will also make use of the default value for the subnet.
Since we want this instance to be a web server,
we'll make use of the user data feature of EC2 to pass in a shell script to install NGINX.
The user data field is under the Advanced Details.
When ready, click on Next.
This will take us to the storage section,
we will leave this to be default value.
There is a single 8GB GP2 disk,
which is an SSD type disk that will be used to create the root partition.
Click Next,
and we can now add some tags to our instance.
Let us add a tag called Name with the value of web server.
Next, we can configure security group for this instance,
we should be able to SSH to this machine.
Let's create a new security group,
and let's call it SSH Access.
Let's also add a proper description for this group.
Under the Type, you'll find a drop-down
with several different types of firewall rules,
but we are only interested in an inbound rule that will allow SSH access,
so leave the default value as it is.
Since the source is set to 0.0.0.0/0,
this will mean that the SSH connection is open from the entire world.
While this is not a recommended setting for a production server,
it will do for this demo.
Next, we can review the instance configuration.
Once you're happy with it, click on Launch.
As soon as we click it,
we will get a pop-up notification to use an existing key pair
or to create a new key pair.
Since we do not have a key pair created in this region yet,
we will want to create a new one.
Let's call it Web, and once that's created,
download it to the machine.
This will be later used as an authentication mechanism
to SSH to our instance.
Next, click on Launch instance.
This can take a few minutes, so please be patient.
Click on View instances to check the status of this EC2 instance.
We have one EC2 instance called Webserver which is in a running state.
Click on it and we should be able to see all the details about this instance.
In the Details section, we can see the public IP
created for this instance.
Let's copy it into the clipboard.
We can also see information such as the VPC,
subnet, the instance type, and the AMI ID that's used for creating this instance.
In the Security tab, we can see the security group that we created.
Under the Networking tab,
we can see public IPv4 address as well as the private IPv4 address
which is created for this instance.
Under the Storage tab, we can see the EBS volume that is used by this instance.
Now, let us use SSH to get to this instance from the terminal.
Here I am inside the terminal of my local machine.
To SSH into the instance we will use the SSH command
and pass in the private key called Web that we downloaded from the console.
The user for this instance is Ubuntu,
and we'll make use of the public IP that we copied from the console.
The first time you run this command,
you may run into an error like this.
This is because the private key file is open
and does not have the correct permissions.
To fix this, use the chmod command
and change the permission to 400 keeping only read permission for the owner.
If we run the command again, we should be able to SSH into the instance.
Finally, let's see if NGNIX was installed and started on the server.
To do this, let's run the command system CTL status NGNIX.
As you can see, NGNIX was installed and it is in a running state.
That was a quick demonstration video
to show you how to launch an Ubuntu EC2 machine
using the AWS Management Console
and to install enable and start NGNIX on it using the user-data feature of EC2.