azure - Terraform 无法列出提供商注册状态

标签 azure terraform

在运行 init 后,我​​尝试在包含 tf 文件的文件夹上运行 terraform apply。

但是,我收到以下错误:

Error running plan: 1 error(s) occurred:

  • provider.azurerm: Unable to list provider registration status, it is possible that this is due to invalid credentials or the service principal does not have permission to use the Resource Manager API, Azure error: resources.ProvidersClien t#List: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Stat us=403 Code="AuthorizationFailed" Message="The client '17cd0b64-08fb-48db-ad9f-4dd56361bb47' with object id '17cd0b64-08 fb-48db-ad9f-4dd56361bb47' does not have authorization to perform action 'Microsoft.Resources/subscriptions/providers/re ad' over scope '/subscriptions/9a305d25-7f89-43d4-a691-62ad0f63c5c8'."

tf 文件包含我的租户 ID、订阅 ID 以及所有其他必填字段,但错误不断发生。请指教?

编辑:下面是我的 tf 文件

  provider "azurerm" {
     subscription_id = "****"
     client_id       = "**client_id**"
  client_secret   = "****"
  tenant_id       = "**+*"
}



# Create a resource group
resource "azurerm_resource_group" "production" {
  name     = "productiongs"
  location = "West US"
}

最佳答案

服务主体似乎没有分配Contributor 角色。

只需转到门户中的订阅,选择访问控制 (IAM)添加角色分配>、服务主体的贡献者

enter image description here

Or follow these instructions

关于azure - Terraform 无法列出提供商注册状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46720266/

相关文章:

amazon-web-services - 何时使用terraform vs无服务器框架来部署AWS Lambda和周围资源?

python - Databricks 中的spark-cdm-connector : java. lang.NoClassDefFoundError:org/apache/spark/sql/sources/v2/ReadSupport

c# - Azure AD - 将所有用户基本信息提取到列表中

请求 Azure Web 角色的方法时,C# HttpWebRequest.GetResponse() 挂起

azure - 如何将 'User administrator' 角色分配给 Azure B2C 租户中的服务主体

terraform - 为节点池指定 "dotted"k8s 标签?

azure - 通过脚本连接到 Azure 点到站点 VPN

amazon-dynamodb - terraform 模块中的可选 map 变量

terraform - gitignore .tfvars 但不是 .auto.tfvars

go - 使用 go 解析简单的 terraform 文件