拆除環境
當實驗課程結束後,請銷毀所有 Azure 資源以停止計費。
Terraform 銷毀
Section titled “Terraform 銷毀”在包含 Terraform 設定的目錄中執行:
# Review what will be destroyedterraform plan -destroy
# Destroy all resourcesterraform destroyTerraform 將提示確認。輸入 yes 以繼續。
驗證清理結果
Section titled “驗證清理結果”確認所有資源已被移除:
# Check resource group is goneaz group show --name "$(terraform output -raw resource_group_name)" 2>&1 \ | grep -q "ResourceGroupNotFound" \ && echo "Resource group deleted" \ || echo "Resource group still exists"清理本機狀態
Section titled “清理本機狀態”移除 Terraform 狀態與快取檔案:
rm -rf .terraform .terraform.lock.hcl terraform.tfstate terraform.tfstate.backup還原 DNS/Hosts 變更
Section titled “還原 DNS/Hosts 變更”若您在整合過程中修改了 DNS 或 hosts 檔案,請還原這些變更:
# Remove hosts file entry (Linux/macOS)sudo sed -i '/<CDN_EDGE_PUBLIC_IP>/d' /etc/hosts若您建立了 DNS A 記錄,請透過您的 DNS 供應商將其刪除。