Dividing VPC into server zone and DMZ zone with AWS EC2

## Overview
In this article, we are going to cover on how we can divide the aws VPC into server zone and DMZ zone. Before diving deep, we will go through the basic understanding of VPC, Server zone, DMZ zone and AWS EC2.

<b>what is VPC?</b>
VPC (Virtual Private Cloud) is a service of Amazon Web Service that provide us a logically isolated sections of the AWS cloud where we can launch AWS resources in a virtual network that we define. VPC is also known as the networking layer for Amazon EC2. We can launch our Amazon EC2 instance into our VPC and configure it by modifying its IP address range, create subnets, configure route tables, network gateways and security settings.

<b>what is server zone?</b>
 Server Zone is also known as public zone. It is a kind of network where the main server is hosted here. Any services that are going to be access through the internet will be placed here.
Example: Web Server, Mail Server and etc.

<b>What is Amazon EC2?</b>
AWS EC2 (Amazon Elastic Compute Cloud) is one of the Amazon Web Service that provides secure, resizable compute capacity in the cloud. It offer businesses the ability to run applications on the public cloud.


## Concepts
The main reason that we want to divide VPC into server zone and DMZ zone is that, if we want to run a public-facing web applications while maintaining back-end servers that are not publicly accessible.
The instances in the public subnet can send outbound traffic directly to the internet, whereas the instances in the private subnet cannot. Suppose we have a web server in a public subnet and a database server in private subnet, then the database servers can connect to the internet for software update using NAT gateway, but the internet cannot establish connections to the database servers.

- The diagram represent AWS VPC
    - ![default-vpc-diagram.png](https://qiita-image-store.s3.amazonaws.com/0/211892/fc931b47-560a-f866-f174-bb6a050a0ae0.png)
- These are the steps to follow:
    - <b>Create VPC</b>
        - Open the amazon VPC console at <a href="https://console.aws.amazon.com/vpc/">https://console.aws.amazon.com/vpc/</a>
        - In the navigation pane, choose <b>VPC dashboard</b>, and then choose <b>Start VPC Wizard</b><br>![VPC-dashboard.png](https://qiita-image-store.s3.amazonaws.com/0/211892/add33f8a-e537-2db8-2925-d59e5483a8bb.png)
        - Choose the first option, <b>VPC with a Single Public Subnet</b>, and then choose <b>Select</b>
        - On the configuration page, enter a name for your VPC in the <b>VPC name</b> field; for example, my-vpc, and enter a name for your subnet in the <b>Subnet name</b> field. This helps you to identify the VPC and subnet in the Amazon VPC console after you've created them. For this exercise, you can leave the rest of the configuration settings on the page, and choose <b>Create VPC</b><br><img width="503" alt="Screen Shot 2018-02-20 at 2.06.08 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211892/aa0d9bb7-4331-c14a-81d7-2da94138222c.png">

    - <b>Create Subnet</b>
        - We create two subnets for public zone and private zone
            - Private zone <br><img width="888" alt="Screen Shot 2018-02-20 at 2.18.37 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211892/eb8f5a05-03b1-460a-94c5-1557480712d1.png"> Its IP range is /19. So it has 8000+ available IP address for private network.
            - Public zone <br><img width="838" alt="Screen Shot 2018-02-20 at 2.26.23 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211892/a424e941-0202-1bbc-7223-815f572301d9.png">Its IP address range is /20. Because the private network is using the all the IP address from range 172.21.0.0 till 172.21.31.255.

    - <b>Create Internet Gateway</b>
        - In the navigation pane, choose <b>Internet Gateway</b>, and then choose <b>Create Internet Gateway</b><br>![Untitled.png](https://qiita-image-store.s3.amazonaws.com/0/211892/a30a5b78-064f-61ca-f9f4-16c761e51195.png)

    - <b>Create Public Route Table</b>
        - In the navigation pane, choose <b>Route Table</b>, and then choose <b>Create Route Table</b><br>![Untitled.png](https://qiita-image-store.s3.amazonaws.com/0/211892/fcabeba5-a6cf-82ba-1495-3b3c2bf0e5b7.png)
After creating the Route Table, we need to assign rules for them. In the configuration pane, navigate to Route Tab and click on <b>Edit</b>, after that click on <b>Add another rule</b> and add as following<br>![Untitled.png](https://qiita-image-store.s3.amazonaws.com/0/211892/a6af3ffc-eac5-eb7f-c0eb-ff176f918f60.png)
After that, we have to associate this route table with the server zone's subnet. By doing so, the server zone will become public.<br>
    - <b>Create a NAT Gateway</b>
        - We create NAT gateway to enable the private network for accessing the internet connection.<br><img width="1311" alt="Screen Shot 2018-02-20 at 3.23.35 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211892/0f660282-fd70-d5f3-c962-15370981925d.png">
    - <b>Create a private Route Table</b>
        - In the navigation pane, choose <b>Route Table</b>, and then choose <b>Create Route Table</b><br>![Untitled.png](https://qiita-image-store.s3.amazonaws.com/0/211892/63f00c25-1144-4c31-7f72-45b1fe99ee4a.png)
In the configuration tab assign rule to its and choose NAT that we just created above. After that associate with the private subnet.

Reference <a href="https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Introduction.html">AWS DOCS</a>