provider "azurerm" {
  features {}

  subscription_id = "ad881159-0593-4502-96e4-e2698b790a3d"
}

resource "random_id" "storage_account" {
  keepers = {
    # Generate a new ID only when the value of this variable changes
    always = "true"
  }

  byte_length = 10
}

resource "azurerm_storage_account" "terraform-state" {
  name                     = "st${random_id.storage_account.hex}"
  resource_group_name      = azurerm_resource_group.terraform-state.name
  location                 = azurerm_resource_group.terraform-state.location
  account_tier             = "Standard"
  account_replication_type = "LRS"

  tags = {
    environment = "Terraform"
  }
}

resource "azurerm_storage_container" "terraform-state" {
  name                  = "terraform-state"
  storage_account_name  = azurerm_storage_account.terraform-state.name
  container_access_type = "private"
}

resource "azurerm_resource_group" "terraform-state" {
  name     = "terraform-state"
  location = "eastus2"
}