DevOps Classroomnotes 30/Mar/2023

Problem with Backends

  • If we use the backends using same template for managing different environmets will be tricky.
  • When user 1 tries update Dev it should not stop user 2 to update QA environments
  • The basic idea is to use the same template across environments
  • Terraform has workspaces

Terraform workspaces

  • Refer Here for workspaces docs and Refer Here for terraform workspaces cli
  • Terraform by default assumes the current workspace is default
  • Lets create a workspace called as dev by user 1
  • Refer Here for changes done
  • Now lets create dev environment and apply the changes from user1 and created the qa environment and apply the changes from user 2.
  • Terraform will allow both the users to create in parallel.
  • Used conditional expression for creating a bastion subnet in qa Refer Here for changes and Refer Here for conditional expressions in terraform
  • Terraform allows multiple environments from one template with workspaces


  • Refer Here for the change which used count to create three files
  • Now lets make a small change Refer Here where the second item from list is removed
  • now apply to see the plan
  • Terraform is deleting test2.txt and test3.txt also and then creates test3.txt again to maintain state
  • To solve this problem we can use for_each Refer Here
  • Exercise: Try solving the above problem with for_each

Interpolation in terraform

  • Interpolation can be acheived by using format function or ${var} expresssion

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner