尝试执行 Terraform Init 时出现错误

问题描述 投票:0回答:1

我正在尝试执行 Terraform init,但收到以下错误

│ Error: Failed to get existing workspaces: Error retrieving keys for Storage Account "stmpltfstateprdcus001": storage.AccountsClient#ListKeys: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceGroupNotFound" Message="Resource group 'rg-terraform-prod-centralus-001' could not be found."

这是我的后端配置:

terraform {
  required_version = "~> 1.0"


  required_providers {
    azuread = "~> 3.0"
    azurerm = "~> 4.0"
  }
  backend "azurerm" {
      resource_group_name  = "rg-terraform-prod-centralus-001"
      storage_account_name = "stmpltfstateprdcus001"
      container_name       = "terraform"
      key                  = "mg-PLATFORM-repo-Azure_Lz_Core-branch-main-template-platform_landing_zone.tfstate"
    }
}

我已使用我的帐户登录到 Azure,并且可以看到存储帐户访问密钥。我有完全访问权限

那么这里的问题是什么

azure terraform azure-blob-storage terraform-provider-azure
1个回答
0
投票

在通过当前帐户运行

terraform init
之前,您需要在同一命令行会话中进行授权:

  1. 安装 az 命令行:https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
  2. 运行以下命令来授权并设置默认会话 Azure 订阅:
    az login
© www.soinside.com 2019 - 2024. All rights reserved.