First we make our VPC, connect our Route Tables, Network ACLs, and with a public and private subnet. In those subnets we make our public and private security groups. Then act last we launch our resources. We then make sure that the only traffic that can flow in the private subnet server to the resource is the public subnet server. When trying to connect to the public server we get this error.
We need to change the protocol to SSH in our security group so that we can securely connect to it. Once we do that we can connect to it.
We then try to ping the private server to see if we can communicate with it.
We is a diagram of what is happening with we trying to connect to the private server from the public subnet.
The terminal stalls because we are not allowing any traffic into the private server even if we are allowed to connect to it. The diagram below shows what is happening.
We need to allow ICMP request in so that the private server can respond.
We can see that the private server is responding.
Now we are going to test the connectivity of the public server to the internet. We use the curl command with a valid URL. This is the response we get back.
Finally we are able to connect to the private server from the public server. Also the public server can connect to the internet.