DevOps Classroom Series – 06/Aug/2021

Terraform continued

  • 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 Preview
    • 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=" -var='ntier_subnet_cidrs=[\"\", \"\", \"\"]'


  • 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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin