2017-10-12 103 views
0

我试图在运行init后运行terraform应用于具有tf文件的文件夹。Terraform无法列出提供者注册状态

不过,我得到以下错误:

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 = "9a305d25-7f89-43d4-a691-62ad0f63c5c8" 
 
    client_id  = "b5c92e75-9609-40d4-a64c-8d09be8b3a26" 
 
    client_secret = "CO5FufAOpH!j0r*Rlf0gi^[email protected]{}A=zUZRbsf" 
 
    tenant_id  = "4da92a32-54f3-4287-bbdb-bafbf8b87840" 
 
} 
 

 

 

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

+0

你是21K用户#1,但你问的问题不任何细节,但错误消息,你可以提供的其他东西,比如代码,如何运行命令,设置的环境变量等等? – BMW

+0

你真的发布了你的秘密凭证吗?如果是这种情况,请撤销它们并审核您的设置,以了解使用给定信用完成的任何更改。 –

回答

1

没有看到您的terraform设置很难知道确切的问题,但我猜你缺少你CLIENT_ID和client_secret。

所以,你的供应商将是这个样子:

provider "azurerm" { 
    subscription_id = "..." 
    client_id  = "..." 
    client_secret = "..." 
    tenant_id  = "..." 
} 

点击此处了解详情:https://www.terraform.io/docs/providers/azurerm/

+0

嗯我有指定虽然。我今晚可以在家分享代码。 – dotnetdev

0

看着给定的错误消息,我会说给定的凭据没有对上述所需的权限资源。

perform action 'Microsoft.Resources/subscriptions/providers/read' 
over scope '/subscriptions/9a305d25-7f89-43d4-a691-62ad0f63c5c8'." 

你有没有创建凭据按照给定的指令中

https://www.terraform.io/docs/providers/azurerm/

此外,从https://github.com/Azure/vagrant-azure/issues/127#issuecomment-226659944

"To enable the application for use with Azure RM, you now need to switch to the 'New' Portal:" and further. You need to add that app credential to the Azure portal and give permission. Trick is about adding by name manually as "Type in the name of the application added in the 'Classic' Portal. You need to type this as it won't be shown in the user list. Click on the appropriate user in the list and then click Select"

相关问题