【问题标题】:Terraform and Azure: Unable to provision Storage AccountTerraform 和 Azure:无法预配存储帐户
【发布时间】:2020-06-14 13:32:19
【问题描述】:

我正在尝试配置存储帐户,但运行它会导致错误:

Error: Error reading static website for AzureRM Storage Account "sa12345461234512name":
accounts.Client#GetServiceProperties: 
Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: 
Service returned an error. Status=403 Code="AuthorizationPermissionMismatch" 
Message="This request is not authorized to perform this operation using this permission.\n
RequestId:05930d46-301e-00ac-6d72-f021f0000000\n
Time:2020-03-02T09:09:44.9417598Z"

运行操作系统 Windows 10 专业版。

复制步骤(在安装了 Azure CLI 的 Powershell 中)

  1. az 登录
  2. mkdir 虚拟文件夹
  3. cd 虚拟文件夹
  4. 创建 config.tf
  5. 地形初始化
  6. 地形规划
  7. terraform apply -auto-approve

Config.tf 内容

# Configure the Azure Provider
provider "azurerm" {
  version = "=2.0.0"
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "Australia East"
}

resource "azurerm_storage_account" "example" {
  name                     = "sa12345461234512name"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"

  tags = {
    environment = "staging"
  }
}

不确定我缺少什么,所有其他资源都可以正常工作,只是存储帐户。

【问题讨论】:

  • 这看起来好像缺少权限?您对订阅的权限是什么?
  • 我没有对订阅应用任何权限,所以无论默认设置是什么,我都在使用它。它建议我是订阅的管理员

标签: azure terraform terraform-provider-azure


【解决方案1】:

这是 azure 提供程序中的一个错误,请参阅:https://github.com/terraform-providers/terraform-provider-azurerm/issues/5869

更新您的提供商;好像跟 terraform 版本没有关系。

发件人:

# Configure the Azure Provider
provider "azurerm" {
  # whilst the `version` attribute is optional, we recommend pinning to a given version of the Provider
  version = "=2.0.0"
  features {}
}

收件人:

provider "azurerm" {
  version = "~> 2.1.0" 
  features {}
}

【讨论】:

    【解决方案2】:

    只是补充一下,因为以上都不起作用。在我的情况下,它首先没有工作,然后第二天工作只是为了晚上不再工作......没有改变版本或任何东西,是同一台电脑。

    事实证明,我在 Windows 中运行的 Ubuntu 上的时间设置有偏差。只需运行sudo ntpdate time.nist.gov 来更新时间即可解决问题。

    【讨论】:

      【解决方案3】:

      发现问题。它与 Terraform 有关。 刚刚检查了更新,发现 0.12.21 已经发布(我运行的是 0.12.20)。

      似乎如果运行 AzureARM 2.0.0 那么真的需要最小 0.12.21 才能使其工作。

      【讨论】:

      • 这对我不起作用,而 Doug 提出的答案有效。您能否确认升级 terraform 的补丁版本是否真的解决了这个问题?
      • @aquaraga 是的,当我遇到问题时,一个有效的问题就是简单的提升。我根据问题留下的版本(仍然使用该版本进行填充)
      【解决方案4】:

      @tesharp 遇到的问题相同。 在我的 Ubuntu WSL2 上,以下命令解决了这个问题:

      sudo hwclock -s
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-29
        • 1970-01-01
        • 2016-07-30
        • 1970-01-01
        • 2018-10-09
        • 2021-04-23
        • 2020-05-19
        • 2019-07-28
        相关资源
        最近更新 更多