Course outlines for learning terraform.
expected time | requirements |
---|---|
60 minutes | A computer with Terraform installed. |
Goal: Learn how to store remote state:
You’ve learned to work with a local state file so far. When you work with multiple people, you need to share the same state. If you do not share the same state, you can step on each-others toes when applying code.
With remote state, you basically do two things:
For “generic” use of cloud providers you can follow:
For our environment, we’ll store the state and lock in a azure container.
To store the remote state in Azure, this can be used: (Change MY_STATE_NAME
to something like robertdebock
.
Change the terraform
parameter in main.tf
to this.
terraform {
backend "azurerm" {
resource_group_name = "rg-terraform-cmn-sbx"
storage_account_name = "stterraformcmnsbx"
container_name = "c-terraform"
key = "rg-MY_STATE_NAME-sbx.tfstate"
}
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.26"
}
}
}
main.tf
.terraform init
.