Terraform 狀態 rm 命令 (Terraform state rm command)


問題描述

Terraform 狀態 rm 命令 (Terraform state rm command)

我創建了一個 azure terraform 模板來創建資源組和 vnet。我已經運行了 terraform plan 然後申請。創造了環境。現在,出於測試目的,有人通過 Azure 門戶在同一資源組中創建了一個存儲帳戶。從那以後,每當我運行 terraform plan 時,它都會顯示要銷毀的資源組狀態。

因此我在模板中重命名了資源組,並運行了 terraform plan。它顯示了新資源組的創建以及現有資源組的刪除。

我知道正在發生這種情況,因為 terraform 狀態文件包含現有資源組的信息。我正在嘗試通過以下命令從狀態文件中刪除現有資源組

terraform state rm azurem_resource_group.rg <


參考解法

方法 1:

To remove the reference of the existing resource group in the state file, you could run it without providing the specific resource id.

terraform state rm azurerm_resource_group.rg

enter image description here

You also could show the state with terraform state list.

(by AsterixNancy Xiong)

參考文件

  1. Terraform state rm command (CC BY‑SA 2.5/3.0/4.0)

#azure #terraform #terraform-provider-azure #templates






相關問題

將屬性添加到 Azure 表存儲中的實體似乎會將空屬性添加到表中的所有實體 (Adding property to entity in Azure Table Storage seems to add null property to all entities in table)

帶有 Azure WCF 服務的 Windows 8 應用 (Windows 8 App with Azure WCF Service)

當我嘗試查看連接到 TFS 的網站的部署選項卡時,無法檢索部署歷史記錄 (Failed to retrieve deployment history when I try to view the deployment tab of a web site connected to TFS)

是否可以在單個 Azure 項目中同時使用 New Relic 和 Azure Application Insights? (Is it possible to use both New Relic and Azure Application Insights together in single Azure project?)

有沒有辦法從 Azure 中獲取所有 DocumentDb 資源? (Is there a way to fetch all DocumentDb resoruces from Azure?)

Azure Search .Net SDK 中的複雜類型支持 (Complex Types support in Azure Search .Net SDK)

遠程服務器返回錯誤:(400) 錯誤請求。在 C:\Program Files\WindowsPowerShell\Modules\CosmosDB\3.1.0.293\CosmosDB.psm1 (The remote server returned an error: (400) Bad Request. At C:\Program Files\WindowsPowerShell\Modules\CosmosDB\3.1.0.293\CosmosDB.psm1)

如何從狀態“False(MissingEndpoints)”啟用 kube-system/metrics-server? (How to enable kube-system/metrics-server from status "False (MissingEndpoints)"?)

通過 smtp 從安裝為 azure 中的 IaaS 的服務器發送電子郵件 (sending emails via smtp from a server installed as IaaS in azure)

cosmosDB RU 吞吐量如何強制執行 (How is cosmosDB RU throughput enforced)

在使用 azure 流量管理器和 azure 應用程序網關與 WAF 時實現國家級阻止 (Achieve country level blocking while using azure traffic manager and azure application gateway with WAF)

Azure 計算機視覺將圖像旋轉 180 度 (Azure Computer Vision Rotating the image By 180 degrees)







留言討論