Solution to Exercise to create two more subnets Refer Here
At this moment the template which we developed creates a vpc with 3 subnets, but it has the following problems
- Always uses the same cidr range (What if the user of this template wants some other network range)
- We are creating 3 subnets which almost are have similar structure with different values. Can we do anything here
Optimizations to the terraform configuration.
- The way terraform works it reads all the .tf files in the current directory and executes them as one configuration
- lets create a new file for providers and check if everything works. Refer Here for the changes
- To create parameters in Terraform which user can pass input we create terraform input variables Refer Here
- Refer Here for the basic usage of variables
- Refer Here for the variables added
- Refer Here for the tfvars i.e. variable values added
- The fix for this is the following command
terraform apply -var="ntier_cidr=192.168.0.0/16" -var='ntier_subnet_cidrs=[\"192.168.0.0/24\", \"192.168.1.0/24\", \"192.168.2.0/24\"]'
- Exercise: Install terraform on a linux machine and try to execut the terraform apply with subnets without escape sequence and find if you get the same issue.