第四階段 — 拆除
第四階段將移除計劃所建立的所有資源。terraform destroy 會透過 F5 XC API 刪除受管理的 xcsh_dns_zone
(及其記錄),並更新遠端狀態。
-
確認您的環境目標指向預期的租戶與網域:
Terminal window echo "$XCSH_API_URL"grep '^domain' terraform/terraform.tfvars -
檢視即將被拆除的資源:
Terminal window cd terraformterraform plan -destroy -
在檢視計劃後執行拆除:
Terminal window terraform destroy
驗證移除結果
Section titled “驗證移除結果”確認區域已從 F5 XC 中消失(預期回應為 HTTP 404):
curl -s -o /dev/null -w '%{http_code}\n' \ -H "Authorization: APIToken xF5XC_API_TOKENx" \ "xF5XC_API_URLx/api/config/dns/namespaces/system/dns_zones/xF5XC_DOMAINx"一旦委派的名稱伺服器移除記錄後,公開解析即會停止。
Azure 狀態後端(資源群組、儲存體帳戶、容器)不會被
terraform destroy 移除——它持有狀態資訊,並可跨執行重複使用。狀態檔案會保留,此時記錄的是空白組態。僅在您完全淘汰該環境時,才使用 Azure CLI 移除後端:
az group delete --name f5-sales-demo-tfstate --yes若要重新建置,請從第一階段 — 建置重新開始。