-: Okay, so let's have a play with peering VPCs.
So what we wanna do is to peer our 2 VPCs together.
So the demo VPC and this one I will call it the default VPC
which was the VPC that was created with my accounts.
So we want to peer them together, okay?
This is good.
And to do so, I'm going to prove first
that's the VPCs are not connected.
And so to do so I'm going to go
into my EC2 management console
under instances I'm going to launch an instance
and then I will scroll down.
I will scroll down.
Key pair will choose demo key pair, but will not need it.
And then we'll do network settings will launch this one
in a default VPC and we'll create a security group
launch-wizard-2 that has the SSH rule added in.
So that's good.
Let's launch that instance and we are good to go.
Okay.
So now we have our BastionHost.
Remember that has this website available
and then we have this instance
I'll call it default VPC instance, okay?
And what I want to do is to connect
and make sure this default instance VPC can connect
to the instance in my BastionHost.
Now, if I have a look at the IPS, okay?
We can see that the private ipv4 is more interesting.
So we can have a look at probably not here.
So, if we look at the private ipv4 address
this one is 172.31.36.159.
And this one before was 10.0.0/72.
We can tell there they're in different VPC
because the IP addresses that are private
are very different.
So let's connect to this one, using EC2 instance connect.
Okay, we're connected.
And let's also connect into my BastionHost.
So my instance in my other public subjects.
Okay.
So if we do a curl and then we do 10.0.0.0.72:80,
which is my IP.
So we get a hello world.
So this is working fine, okay?
But if we do the exact same curl command
so we go here and we do curl on this IP, okay?
So this is from the 172.31 type of instance.
So, we're going to curl this instance right here
and press enter.
Well, this is not working.
We get a time out.
Well, because there is no way
for our EC2 instance right now
in this VPC to connect to the two instance in another VPC.
That's why it's called virtual private Cloud IaaS
because they're isolated from a network perspective.
So we're going to connect them.
And to do so,
well we need to go and create a peering connection.
So on the lifeline side, there is peering connections.
I'm going to create a peering connection
and I'll call it demo peering connection,
and we need to select a local VPC to peer with.
So we're going to say that the requester is my demo VPC,
and then we're going to select another VPC to
connect to.
So it's in my accounts, but it could have another account
and it's in this region, but it could be another region.
And the acceptor of VPC is going to be the default VPC
with this CIDR.
So as we can see, this CIDR and that CIDR do not overlap
and therefore this VPC peering connection is
possible to create, okay.
So let's create this peering connection
and it's pending acceptance.
So this is not working until we have accepted it now
because both the VPCs are in our accounts.
We can accept this request ourselves, so we can accept it.
But if it wasn't of other accounts
obviously we could deny it.
So the requester owner ID
and the acceptor or ID are the same in this example.
So let's accept this request.
And now it says to send and receive traffic across
this VPC peering connection
you must adder route to the VPC period
in one or more of your VPC, route tables.
So again, this is very important, even though there's VPC
peering connections we need to still modify the route table.
So again, if I try to do a curl, not from this one
but a curl from this instance, still not working, okay?
So let's go ahead and fix this.
So we go and modify my route tables now.
And so we have one public route table,
and here we have I will find the right one.
So this is this one right here.
This is my default VPC default main route table,
main route table.
Okay, now we know where we are.
Okay, so we want to connect this and that's.
So let's start with a public route table
and I will go to routes and then edit routes
and I will have a destination.
So in this one, we need to select a CIDR, which corresponds
to the CIRD of my VPC that was created the default VPC.
So to do so let's go into your VPCs,
find the default VPC
and the IP four CIRD is right here.
So I'm copying it, I'm pasting it.
And we're saying, Hey, any traffic that is going
into this range of IP addresses
should be sent to a peering connection
called the demo peering connection.
And click on safe changes,
and what we've done effectively is
that we've created a route
from my creative VPC into the default VPC.
So if we try again though
and do a curl, still not working, and the reason is,
well we need to also modify the other route table
for it to work.
And so let's do it.
Let's modify the other route table.
So to do so, I'm going to go into the VPC main route table
and I will edit this route and I will add a route.
And this time it's for 10.0.0.0.0.0/16
which is now the CIRD
of the VPC we've created alongside this course.
And again, the peering connection.
And then we'll say step changes.
So now we have routes going both ways.
And so if I curl again and press enter, here we go.
We'll get a hello world.
That mean that the VPC peering connection is working
and it was established.
Okay?
So that's it, I hope you liked it.
And I will see you in the next lecture.