2017-10-12 42 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"

相關問題