How to build your own private cloud on AWS part 1
Tags: aws, cloud, devops
Published: 2020-09-04 13:35:56

In this series of articles, I will show you how to build your own private cloud on AWS. Here, in [Appus studio](appus.software) we always put the security of applications of our clients first, so we recommend them getting their own VPC with public, private, and full isolated subnets. 
So let’s get started. Open your AWS console and search for VPC. In the left menu bar, you can find “Your VPCs”, left button click on it and all VPCs you have should be visible to you. If you haven't configured your custom one, there is always one default VPC provided by Amazon. Click on “Create VPC” and enter the name of your VPC, CIDR block (range of IP addresses that work in this VPC). In my case, I use this 10.0.0/16 it is 65,536 IP addresses minus 5 reserved by AWS. I will keep all other configurations default because I do not need them.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ptxjrt4vdt0sodyrvqa1.PNG)

Now our VPC is created. The next step is to configure Internet Gateway and attach it to our private cloud to have Internet access. On the left menu bar find the “Internet Gateways” tab and by default, there is just one provided by Amazon. Click on “Create internet gateway”, name it, and hit “Create”. Now it has a detached state, to attach it all we need to do is click on “Actions” -> “Attach to VPC” -> and select your VPC.
So we have created our VPC and attached Internet Gateway to it. The next step is to create our subnets. Left click on “Subnets”. By default, it has as many subnets as your region has availability zones. We will create our subnets in two different availability zones. Hit “Create subnet” and fill out the “Name tag” box, choose your VPC, choose one of the availability zones that Amazon provides in your region and enter the CIDR block for this subnet.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5876xojz7xtteztlx99o.PNG)

Let’s configure the same public subnet but in another availability zone.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v4pi96lbbk38hlvge8ca.PNG)

Now we need to tick auto-assign public IPv4. Choose your subnet and hit “Actions” -> “Modify auto-assign IP settings” -> “Enable auto-assign public IPv4 addresses”-> “Save”. These steps are for public subnets.
Now we will modify our route table for our subnets to be able to access the Internet. Now go to “Route tables” -> choose your route table -> “Actions” -> “Edit routes” -> “Add route” -> Destination(0.0.0.0/0) and Target Internet Gateway and choose yours -> “Save routes”.
The next step will be to create a private subnet in different availability zones.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b20kcnr2dkframvkgsgw.PNG)

And another one:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sgc2n3ht75qpxcb0jrux.PNG)

When a private subnet is created we need to configure the route table for it. On the left menu bar click on “Route tables” -> “Create route table” and create new route tables for first and second private subnets.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gvdjlelzsryt7lc84lac.PNG)

Then we need to attach this route table to our private subnet. Click on your private subnet, then “Subnet Associations” -> “Edit subnet associations” then choose private subnet –> “Save”:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ybvz0qwmy6axwhb06qvh.PNG)


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9i3f6nll5it42d3cnjj7.PNG)


So let’s configure isolated subnets in two availability zones.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jp23msfqbukjkas38814.PNG)

And another one:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/49k3g3gbipd0158ufjim.PNG)

And now we will create a new route table for our isolated subnet:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/td8lclb0kbbhynjho8hc.PNG)

Now attach it to our isolated subnets:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dr75m6lwfgul37ytmm9y.PNG)

We have come a long way. Now we will configure NAT for our access to the Internet from private subnet. Click on “NAT Gateways” -> “Create NAT Gateway”. NAT will be attached to public subnets and it needs an Elastic IP address. If you do not have one, just click on “Allocate Elastic IP” -> “Create NAT gateway”

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v9s1p4zikn9ri8su3r98.PNG)

We need 2 Elastic IP addresses for subnets A and B. So I will create another one but with another public subnet. It will take some time for NATs to switch to the available state. If you did everything correctly you will see this:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jqmb4jq1fknmo63dq1wi.PNG)

Now we will attach those NATs to our route tables. We will attach NAT-A to private subnet A and NAT-B to private subnet B:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1bvzrl7nau0g18wg7ib7.PNG)

And for another one:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1f4fpvttm94iv8nwqp25.PNG)

Finally, we are done and here is the result of our work:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bidl27m5u7zq977mstqg.jpg)

In the next part we will test our environment. See you soon!