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
    Preview
  • 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
    Preview
  • Lets create a workspace called as dev by user 1
    Preview
  • 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.
    Preview
  • 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

Problem

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

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube