This post is part of complete guide on how to deploy WordPress on AWS using Terraform

Before we dive deep into VPC it’s important to understand CIDR. I have a short post about it https://claretcloud.com/technology/what-is-cidr/.

In AWS you can have multiple VPCs in an AWS region currently is max of 5 per region – soft limit, you can increase it. 

  • Maximum CIDR per VPC is 5, for each CIDR
    • Maximum CIDR submask is /16, 65536 IP addresses
    • Minimum CIDR submask is /28, at least 16 IP addresses

It very important to make sure your VPC CIDR does not overlap with your other networks

Create main.tf file and add the code snippet below:

provider "aws" {
}

# vpc
resource "aws_vpc" "aws-vpc" {
  cidr_block           = "10.0.0.0/16"
  instance_tenancy     = "default"
  enable_dns_hostnames = true


  tags = {
    Name = "aws-vpc"
    env  = "dev"
  }
}

Next run:

 terraform apply 

Go to AWS console you should see your vpc created..

At the end of this post we have our architecture looking like this.

AWS VPC

Note: Don’t forget to clean up if you plan to continue later if not ignore.

destroy resources in terraform

terraform destroy

Categorized in: