DEV Community

Cover image for How to create a VPC, subnet, and networking setup in AWS using terraform?
Nilesh Mahajan
Nilesh Mahajan

Posted on • Originally published at walkthrough.so

How to create a VPC, subnet, and networking setup in AWS using terraform?

Overview

AWS is a very big and complex platform. Creating a SAAS on AWS can be a daunting task, especially if you are not familiar with AWS. There are so many configurations about VPC, subnets, security groups, etc to be created before you even begin provisioning your application/database servers. The UI and documentation can be very confusing.

So I prefer a script/code-based approach to creating infrastructure. Terraform is a popular choice to create your AWS infrastructure programmatically. This how-to guide helps you create a basic networking stack using terraform that you can use to create your SAAS. 

What you will create?

If you are starting a new SAAS project and planning to run your infrastructure on AWS, then you are going to need 

A VPC1 public/private subnet per availability zoneNetworking set up like a public internet gateway and a private NAT gatewaySecurity group to control ingress/egress traffic 

The overall setup will look like below - 

Our Setup

What you will need?

AWS Account with programmatic access Terraform (>0.12) installed on your operating system and binary is included in your system's PATH. 

If you are using mac, you can get terraform using homebrew easily.

 

$ brew tap hashicorp/tap
$ brew install hashicorp/tap/terraform

# To verify everything is right, check version 
$ terraform version
Terraform v0.15.1
on darwin_amd64
Enter fullscreen mode Exit fullscreen mode

Continue reading this ...

The remaining steps to build this are available in a nicely written walkthrough here -

https://walkthrough.so/pblc/pHjklthzWFvI/how-to-create-a-vpc-subnet-and-networking-setup-in-aws-using-terraform

Top comments (0)