我正在使用 Terraform 部署一个 azure 基础架构。terraform 状态将存储在与主部署订阅不同的订阅中。我在提供者声明中使用别名。我的地形代码如下:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 2.38.0"
}
}
backend "azurerm" {
resource_group_name = "resourcegroup_name"
storage_account_name = "storageaccount_name"
container_name = "mystate"
key = "tfstatename1.tfstate"
}
}
provider "azurerm" {
features {}
}
provider "azurerm" {
features {}
alias = "second_subscription"
subscription_id = var.second_subscription_id
}
我的 terraform 状态应该以别名存储在订阅中。
我怎样才能做到这一点?