DevOps Classroomnotes 13/Aug/2023

Terraform contd


  • Lets apply backend to ntier-aws to store in s3 bucket Refer Here
  • Refer Here for the changes
  • As we have observed when multiple users try to execute at the same time only user gets the lock and others user have to wait till the lock is released


  • Refer Here for azurerm backend
  • Refer Here for the changes done to accomodate backends
  • Refer Here for the new vars for a qa environment
  • Create a new workspace qa
  • Once we create state file will be stored with qa information.
  • Exercise: Try doing the same workspace concept in aws.



  • Terraform workspaces allows us to create multiple environments from the same template.
  • By default we were working with a workspace called as default
  • Refer Here for official docs

Other topics

resource "aws_s3_bucket" "item" {
  count      = terraform.workspace == "default" ? 1: 0
  bucket     = random_string.bucket_names[count.index].id
  depends_on = [random_string.bucket_names]

resource "random_string" "bucket_names" {
  count   = terraform.workspace == "default" ? 1: 0
  length  = 8
  special = false
  lower   = true
  numeric = false

Activity: Importing terraform resources

  • Azure:
    • Create a resource group
    • create a new folder in your system and configure terraform azurerm provider
  • AWS:

    • Create a vpc
    • create a new folder in your system and configure terraform aws provider
  • import command Refer Here
  • Refer classroom video for importing resources

Exercise: Make a note of observation

  • Create 3 s3_buckets/storage_accounts resources
    • delete one resource from terraform and reexecute apply
  • Out of 3 resources i dont want terraform to control one resource any more
  • importing a new resource into terraform state

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner