Create a tiny Terraform workload with local state first.
Why:
- We need a known local
terraform.tfstatebefore we migrate it to Azure backend. - This makes the migration step reproducible and verifiable.
Workdir:
infra/workload/01-local-state
terraform {
required_version = ">= 1.6"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
}
provider "azurerm" {
features {}
}resource "azurerm_resource_group" "workload" {
name = "rg-workload-runbook"
location = "westeurope"
}Run (local state)
cd C:\Git\terraform-azure-backend-oidc-runbook\infra\workload\01-local-state
terraform init
terraform applyConfirm with yes if prompted.
Verify local state exists
Get-ChildItem -ForceExpected to see:
-
.terraform/
-
.terraform.lock.hcl
-
terraform.tfstate
Before proceeding to Step 03:
-
Azure resource group rg-workload-runbook exists
-
Local terraform.tfstate exists in the workdir