DevOps Classroom notes 25/Sep/2024

Multiuser Executions in Terraform

  • Terraform is storing the state in local folders
  • Consider the scenario where a terraform template has to be executed by any team member to create a dev environment
  • The default location is local folder, the state has to be in common location which is accesible to all team members
  • Locking is required for giving access to only one a time
  • The above discussed features can be done in terraform with the help of backends

Terraform Backend

  • Refer Here for official docs
  • As discussed in the class have a look at following backend configuration to use s3 backend
terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "5.68.0"
    }
  }
  backend "s3" {
    bucket = "terraformbackendforlt"
    key    = "demo/terraform.tfstate"
    region = "ap-south-1"
    dynamodb_table = "myterraformstate"
  }
}

provider "aws" {
  # Configuration options
}
  • Findout how to use azurerm backend, as we have tried in the class the following providers section was used
terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "4.3.0"
    }
  }
  backend "azurerm" {
    resource_group_name  = "terraformstate"
    storage_account_name = "lttfstaterepo"
    container_name       = "state"
    key                  = "demo/terraform.tfstate"
  }
}

provider "azurerm" {
  # Configuration options
  features {

  }
}

Handling multiple environments

  • Consider the following template
    Preview
  • In this template we have two tfvars with different variable values
  • The problem with backend configuration is it is designed to manage only one environment
    Preview
  • To solve the above mentioned problem we will be workspaces with backends

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
Plugin for Social Media by Acurax Wordpress Design Studio

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