So I want to demo how DNS works in AWS,
but for this, I'm going to create an EC2 instance
into two regions, and then I'll use Route 53
to redirect to these instances.
Using Route 53 is not free,
you have to pay $12 a year to get a domain name,
and then you have to pay 50 cents a month
to have the DNS on AWS.
So if you want to remain within the free tier,
don't follow the hands-on with me,
just watch what I'm doing, okay?
So let's do an example. I'm going to be in Ireland.
So I'm going to create an EC2 instance in Ireland,
and I will configure it to say, hello from Ireland.
So here we go.
I'm going to lunch an EC2 instance.
We have been doing this so far a lot of times,
so I'll go a bit faster.
So we have a t2 micro.
And then for the user data,
I will be using the one from before,
but I will say hello world from, and I will just have it,
I will replace that bit.
And I will just say, hello world from Ireland.
Here we go.
And then I will review and launch it.
And then I need to edit the security groups, of course.
So I'll edit the security group
and will choose the launch-wizard-1.
Review and launch, launch it,
and then launch my instance.
So this is going to launch an instance into my first region.
And I'm going to keep the IPv4 public IP of this one.
And I will have it in a textbook right now, just to keep it.
And this is from Ireland.
Okay, next I'm going to launch the exact same instance,
but in another region, for example, in America.
So I'm going to go to the West Coast.
I'm going to go to Northern California.
And I'm going to create yet again, an EC2 instance.
So for this, there's going to be a bit more latency,
because I'm not close to California.
So I'm going to launch an instance.
And as you can see, it's slower for me
to do AWS-related actions because there is more latency.
So this is a good example of what latency looks like.
So I'm going to use Amazon Linux 2, I'll select this.
I'll use the t2 micro.
And in this time, I will also use the user data,
but I will copy it from before.
And I will say, hello from, and then I will type California.
Okay, hello from California.
Then I'll add the storage.
And then I will add tags.
I will configure a security group.
In this case, I don't have a security group available for me
because security group are created on the region basis.
So I need you to create a new one.
And I will allow HTTP in from everywhere.
So this is good.
Review and Launch.
And then it will launch it.
And we could create an existing, a key pair.
Again, key pairs are per region.
So we don't have one right now,
but it can proceed without a key pair,
because we're not going to SSH
onto our instances using this hands-on.
So I'm going to launch my instance.
And again, I'm going to get the IP out of that instance,
which is right here, the public IPv4.
And then I will have it in my text file
just to remember what it is.
Okay, so now let's test it out.
So let's make sure that we can connect
to our EC2 instance in Ireland.
Yes, we can.
It says, hello world from Ireland.
And I expect the one from California to work very soon.
In the meantime, what we have to do is play with Route 53.
So I'm going to open the service.
And the first thing I have to do is to buy a domain name.
So as we can see, the service is a global service.
It does not require any region selection.
So there's another global service in AWS.
And so I'm going to get started with a domain registration.
As I said, this is going to cost you money.
So if you don't want to do it, then just watch me do.
I'm going to register a domain.
And I have to choose a domain name.
So stephaneccp.com.
Let's see if someone took it.
And no one took it.
It's available for me.
So I'm going to buy it for $12 a year.
I'll add it to my cart.
And then I will click on continue.
Then I have to register my information.
So I'll just do that offline.
And then my order is completed.
And it will take a bit of time to get processed.
So for this, I can go to my domains
and I can see the domain registration is in progress.
Now this should take about five minutes.
But in the meantime, let's check
if our California instance is also working.
So I'm gonna go, open a new tab, press enter.
And yes, it says, hello world from California.
So if this is not working for you.
This is maybe because the EC2 user data was wrong
or maybe because the security group rules
are not allowing the traffic in.
So make sure to check these things,
but you should have an instance in Ireland
and an instance in California.
Okay, great, so now let me wait
for the domain registration to be completed.
So my request is now completed.
And if I go to registered domain,
I can see that this is working.
Now, let's go into hosted zones on the left hand side.
And we can see that a hosted zone was created
for my domain, stephane-cpp.com.
And I'm going to create my first Route 53 record
in this hosted zone.
So for this, I am going to create my first record sets.
And this is going to be www.stephanecpp.com.
This is going to be your A record of IPv4 addresses,
and then I have to choose the value of it.
So the routing policy, first of all,
is going to be Latency, why?
Well, because I want to make sure that we are redirected
to the EC2 instance that is the closest to me.
So either Ireland or California.
And then I need to specify a region.
So for example, I will say, okay, this first of all,
this first instance right here, corresponds to Ireland.
So we'll select the region Ireland, which is eu-west-1.
And then I will call this My Ireland EC2 Instance.
And in here, I will add the IP of my instance
as the value of my A record.
And you need to make sure to remove the HTTP.
So just IP right here.
And this is our first record.
And we'll create it.
Okay, and then we're going to create a second record
for my instance in California, so www.stephanecpp.com.
And A record, yet again.
And the value is going to be this IP.
So again, I need to remove the HTTP.
And then the routing policy is going to be Latency.
And this time, we are talking about the region us-west-1.
And I'll call it My Californian Instance.
And click on Create.
So now I've created a record for www.stephanecpp.com
that has two destinations based on the latency.
One is for Ireland and one is for California.
So how can we test this?
Well, let me try to connect to www.stephanecpp.com.
And because I'm in Europe, I'm expected
to reach the Ireland instance.
And yes, it says, hello world from Ireland.
So if I keep on refreshing this page,
all I get is hello world from Ireland.
But I've a small utility called the VPN.
And I can connect, for example,
to the United States using my VPN.
So I'm connecting to the United States right now,
and it will be connected in about a second.
Here we go, I am connected to the United States.
And so now I look like a user from the U.S.
And so what I will do now
is I will open a new web browser window
and then I will paste the same URL, press enter.
And now the response I'm getting
is hello world from California.
So we can see the users
from California are redirected to California,
and the users from Europe are redirected to Europe.
And if I try one more time to connect to a new location.
For example, if I tried to connect to India
and see what instance I get redirected to,
I would bet that I will be redirected to Europe,
because India is closer to Europe than the U.S.
but let's see, we never know.
So I am connected into India.
I'm going to open a new web browser,
enter stephanecpp.com, press enter,
and I am redirected to Ireland.
So this was a cool demo to see
how a latency record works in Route 53.
And if you wanted to play around, you could play
with other types of records, such as Weighted,
or Simple, or Failover.
But all I want to show you is that's in Route 53,
which is a very complicated system,
you can set up a way to have a latency-based records,
which allows you to redirect your users
to the closest location for them to minimize their latency.
So finally, to you finish this hands-on,
please don't don't forget to delete
and terminate all the EC2 instances
in the various regions you have in AWS,
otherwise, you will incur some cost.
So for this, go to Northern California
and terminate the instance.
And then go to Europe and terminate the instance as well.
And that's it.
You terminate instance in one and two regions.
And then for your DNS, you will have a 50 cents a month cost
if you keep the hosted zone.
So you can delete the hosted zone if you wanted to,
but remember, if you did buy a domain,
then the domain costs you about $12,
and this is something you cannot avoid, okay?
So, I hope you liked this hands-on,
and I will see you in the next lecture.