- Now let's run through a demo of launching a Linux instance
in Amazon EC2.
You can see, we're already logged into the AWS console.
We're on the initial dashboard, and from here,
I'm gonna go to EC2.
It's important to make sure that you're in the right region.
Here, we're using the US East two Ohio region.
I can change that from here.
Again, as we've talked about,
whatever region you operate in is really according
to the needs of your business.
Are you trying to serve end-users in a particular area?
Are you trying to meet some kind
of data compliance regulations?
Or are you simply trying to get the lowest cost?
Whatever that answer is will determine
what region you choose.
For the sake of this demo, it doesn't really matter,
but US East is one of the newer regions,
so I just wanna try it out.
I've seen this happen to folks, when you launch machines,
and you launch different resources,
and then you come back later and go,
"Wait, where are they?"
It's simply because you inadvertently switched
to a different region.
If that happens to you, if you can't find your resources,
just make sure that you have the right region selected.
From here, in the Ohio region, you can see
that we don't have any instances running.
In order to launch one, I going to go down here to AMIs.
Remember what we talked about,
that all EC2 instances start with the Amazon Machine Image,
so I'm gonna click on that.
You can see that I have this filtered.
I'm gonna change this real quick to show you.
Images owned by me: I don't have any yet.
I'm gonna change this to Public Images.
These are all of the images that have been made public
by various publishers, namely being Amazon Web Services.
Other folks like Canonical publishes Ubnutu.
Red Hat publishes a number of things like, of course,
Red Hat Enterprise Linux, CentOS Fedora.
There's others, like Zend and VIATA.
All kinds of public images are available here.
For the sake of this demo,
I want to launch an Amazon Linux-based machine.
You can see, when I click here into the filter,
I get a number of attributes
by which I can filter our images on.
The first thing that I wanna do is filter by,
I know that this is Amazon Linux,
so I'm gonna change the owner to Amazon Images.
Now I can see that all of these images were published
by Amazon Web Services.
I'm going to, also, change the platform to Amazon Linux.
I'm going to make sure that the architecture is 64-bit.
From there, you can see, if we were to scroll through here,
we could see that the list did get shorter.
It's hard to see that, but we have narrowed it down.
This is the one that I want; I want X86 64.
The EBS that we see here means
that the root volume is based
on an elastic block-store volume.
We'll talk more about that later.
Now that I have the AMI that I want,
I'm gonna go ahead and hit Launch.
From here, you can see, we can choose
from various types of machine sizes.
We have different families, such as the t2 family,
which is really great for development, testing,
environments, experiments.
It's potentially good for low-traffic applications
in production as well.
We have the M series, which is a mixed-use.
They give us a good balance of CPU, here two cores
and eight Gigs of RAM for the m4.large.
If we compare that to the c4.large, you can see
that we have two cores, but we have half the memory.
The c4 is what we consider a compute-optimized instance.
It has less memory, but essentially more compute power.
We get into the R series,
and that's going to give us much more memory.
These are memory-optimized.
We get into some really large storage capacity.
These are high-performance computing.
We can even get into the GPUs, and so on and so forth.
For now, for the point of this,
we don't really need a whole lot.
In fact, the t2.micro is free-tier-eligible.
You can see that certain instances, like this one here,
Amazon Web Services will give us the first 12 months
of this particular machine for free, that is,
the first 12 months following your AWS sign-up date.
My particular account is too old for that.
I don't qualify for the free tier, but for those
of you following this course, you probably will.
Using the free tier services, a number of services come
with a free tier, it's a really great way to get
into Amazon Web Services and try things out,
and get to know these services without spending any money.
I'm gonna go ahead and choose the t2.micro.
I'm going to click Next.
From here, we can say, I want to launch one,
maybe I wanna launch 10 machines.
We can change that if I wanted to.
For the sake of this demo, we're just gonna launch one.
Here, we'll talk about Spot instances later on.
We might wanna choose this; we wanna get a lower price.
We'll save that for later.
Here, we can choose the network.
Here are the networks that we created earlier.
For the sake of this demo, I'm gonna launch this into 10.2.
Because I don't have a VPN established right now,
I need these machines to be publicly available.
I'm gonna choose one of our public subnets that we created.
I'm also going to make sure
that the auto-assign public IP is using the subnet setting
that we turned on, so that, yes,
these machines will automatically get a public IP.
Can recall that we talked about roles.
I'm going to choose the myApplication role that we created,
so that later, if I want this particular instance
to have the ability to communicate with other AWS services
on my behalf, then it already has a role
and I can just go in and add permissions to that role.
It's important to know that you have to add the role
at the time you launch the machine.
If you launch a machine without a role, it's too late.
You'll have to terminate that machine and start over.
From here, you can see that we do have some control
over our network interfaces.
We could add more if we wanted to.
There are some advanced options down here,
such as user data that we'll talk about later.
We're gonna click Add Storage.
From here, you can see
that our root volume is an eight-Gig volume.
It's just a simple magnetic volume,
and it will be hosted by the elastic block-store service
that we'll talk about later.
Now, if I wanted it to be faster,
I might wanna choose a General Purpose SSD
or a Provisioned IOPS SSD.
Again, we'll talk about those later on.
For the sake of this demo, magnetic is perfectly fine.
We're gonna click Next and add some tags to my instance.
Tagging is a really great way
to keep your environment organized.
As you get further into Amazon Web Services,
as you start to deploy applications and services,
you'll end up, perhaps, with dozens or hundreds
of EC2 instances, security groups, VPCs.
It's really important to be able to tag these resources
in a consistent way, in a predictable way,
so that you can come back and filter
and find particular servers for particular needs.
In this case, I'm going to name this one linux-demo.
I might also want to create other tags,
such as the environment that this machine belongs into.
The environment might be dev, stage, production, and so on.
I might also add an application tag, and call this one demo.
Tags are up to you.
They're pretty much arbitrary, but again,
I would highly recommend that you leverage these
as a way to keep your infrastructures organized.
From here, I'm gonna leverage the security group.
I'm going to select an existing one,
because we already created one.
I'm going to use the web server that we created.
You can see here that we have our port 80
and 443 is open from the Internet.
I'm gonna go ahead and click Review and Launch.
It's just telling me, you know what?
Port 22, you don't have access to that,
so we're going to fix that here in just a minute.
It's also saying it's somewhat warning us
that we are continuing with a magnetic drive.
It's telling us that General Purpose SSD volumes
will be faster, and it's giving us the choice
to make our boot volume General Purpose
for all instances going forward, or just for this one,
or we could just continue with magnetic.
Perhaps I'm just gonna say, you know what?
General Purpose SSD is probably better.
Let's go ahead and stick with that
for all things moving forward.
That'll be up to you.
Whatever makes the most sense for your business.
Now we get an opportunity to review this instance.
I'm going to scan through here and make sure,
yes, we're using an Amazon Linux, AMI.
We're running on a t2.micro.
We have the right security group attached,
with the right rules in place.
Just take a quick look at the storage.
We don't really need any more than eight Gigs,
so that's gonna be okay.
Make sure that we have the right tags in place.
We have our name, our environment, our application.
I'm gonna go ahead and click Launch.
Now, key pairs are necessary for logging in
to the operating system of this particular machine.
I don't have an existing key pair.
You can see that I don't have any yet,
so I need to create one.
I'm going to say, create a new key pair.
I'm gonna call this one aws-livelessons,
so I can use this for other things.
At this point, if I don't download the key pair
at this point, then I will never be able to get it.
Amazon Web Services only gives us this one opportunity
to download the private half of that key pair.
From that point, that private key is not kept by AWS.
If we don't download it here,
we'll have to go back and create a new key pair.
If you lose the private half of that key pair,
you won't be able to get into your instance,
unless you have already configured your instance
to allow login without private keys.
So, I'm gonna go ahead and download this key pair.
You can see, there it is.
We have a .pim file that we're going to modify here
in just a minute.
Now that we have the key pair created and selected,
I'm going to hit Launch Instances.
There you go; now you can see
that our instance has launched, and I can click here.
This is the ID of the instance.
I'm going to click that, and it will take us
to the Instances Dashboard, where we can see
that our t2.micro is now running
in us-east-2a availability zone.
From here, we can see that we have a public IP
that was automatically granted to it.
We can see that we also have a private IP in the 10.2 range.
From here, what I need to do is make sure
that this particular machine can be reachable over port 22.
Really quickly, what I wanna do
is create a new security group.
I'm gonna call this one ssh.
Make sure that it belongs to the right VPC.
I'm going to add SSH from My IP,
you can see here that it selected the right IP
that I'm currently coming from.
I need a description.
Then I'm gonna create that.
Now that we have our ssh security group,
I'm gonna click this tag here
and make sure that that also has that name.
I'm gonna come back to our instance.
I'm going to make sure
that we have that instance highlighted.
Going to go to Networking, Change Security Groups,
and choose the ssh security group.
Now that we have that, you can see here,
here are our security groups.
I'm gonna click those View Rules
and make sure that port 22 is open,
port 80 and 443 are open.
From here, I'm going to copy this public IP address.
I'm going to make sure that I have access
to that PIM file that we downloaded.
There we go.
Now I'm going to ssh, using that key.
Now that we have our key downloaded,
I want to shell into that instance.
I wanna make sure that I have the appropriate permissions
on that key, so I'm going to change those to 400.
Now that the key has the right permissions,
I'm going to use that.
In the case of Amazon Linux, the superuser is ec2-user@,
there's the public IP of our instance, and there we go.
Now we've logged in.
You can see we have a shell into our t2.micro,
running Amazon Linux, and that's it
for launching a Linux instance on an Amazon EC2.