清除環境
實驗課程結束後,請銷毀所有 Azure 資源以停止計費。
Terraform 銷毀
Section titled “Terraform 銷毀”在 terraform/ 目錄中執行:
cd terraform/
terraform plan -destroy
terraform destroyTerraform 將提示確認。輸入 yes 以繼續。
驗證清除結果
Section titled “驗證清除結果”確認所有資源已被移除:
RG_NAME=$(terraform output -raw resource_group_name)
az group show --name "${RG_NAME}" 2>&1 | grep -q "ResourceGroupNotFound" \ && echo "Resource group deleted" \ || echo "Resource group still exists"
az resource list --resource-group "${RG_NAME}" -o table 2>/dev/null清理本地狀態
Section titled “清理本地狀態”移除 Terraform 狀態及快取檔案:
rm -rf .terraform .terraform.lock.hcl terraform.tfstate terraform.tfstate.backup保留結果(選用)
Section titled “保留結果(選用)”若您希望在銷毀虛擬機器之前保留流量套件結果,請將其複製到本地端:
TGEN_IP=$(terraform output -raw public_ip)
# Copy all results to local machinescp -r azureuser@${TGEN_IP}:/opt/traffic-generator/results/ ./traffic-results/
# Or copy just the latest runLATEST=$(ssh azureuser@${TGEN_IP} 'ls -t /opt/traffic-generator/results/ | head -1')scp -r azureuser@${TGEN_IP}:/opt/traffic-generator/results/${LATEST} ./traffic-results/F5 XC 清除
Section titled “F5 XC 清除”若您也希望移除流量產生器所指向的 F5 XC 設定:
- 刪除 HTTP 負載平衡器
- 刪除來源池
- 刪除為測試所建立的任何 WAF 政策、Bot Defense 設定、API Security 政策或 CSD 設定
這些 F5 XC 資源不會產生 Azure 費用,但在示範環境不再需要時應予以清除。