今天遇到一个 GCP Billing 的坑。
明明已经给账号添加了:
Billing Account Administrator但在项目里绑定结算账号时却提示:
没有有效的结算账号
您的所有结算账号均已关闭奇怪的是,Billing Account 页面又可以正常打开。
解决方法
打开 Google Cloud Shell,先检查 Billing Account:
gcloud billing accounts describe 01A2BC-34DE56-78FG90如果看到:
open: true说明 Billing Account 实际是正常的,只是 Google Cloud Console 没有正确显示。
然后查看项目 ID:
gcloud projects list假设项目 ID 是:
demo-project-123456直接绑定:
gcloud billing projects link demo-project-123456 \
--billing-account=01A2BC-34DE56-78FG90最后验证:
gcloud billing projects describe demo-project-123456如果看到:
billingEnabled: true就说明绑定成功了。
总结
如果 GCP 网页提示:
您的所有结算账号均已关闭但执行:
gcloud billing accounts describe BILLING_ACCOUNT_ID显示:
open: true可以直接使用:
gcloud billing projects link PROJECT_ID \
--billing-account=BILLING_ACCOUNT_ID绕过网页直接绑定。
这次的问题本质上就是:Google Cloud Console 没有正确显示 Billing Account,但 CLI 可以正常操作。