Build a tf file to create VPC usig Terraform tool
- To install terraform, run the below commands :
$ wget https://releases.hashicorp.com/terraform/1.0.11/terraform_1.0.11_linux_amd64.zip
$ unzip terraform_1.0.11_linux_amd64.zip
$ mv terraform /usr/bin/
$ terraform version
- Create a directory mycloud ad navigate into it
$ mkdir mycloud
-
Mention the IAM authentication and region in the provider file
-
Set the envirnonment variables (region, vpc_cidr,subnets) in the variables file
-
Execute the below commands :
$ terraform init
$ terraform validate
$ terraform plan
$ terraform apply
A VPC is created with Internet Gateway, 6 Subnets including 3 public & 3 private, Elastic IP, NAT gateway, Public and Private Route tables and the Route table Association.