簡體   English   中英

如何恢復 GCP 項目服務帳號

[英]How to recover GCP project service account

我無知地刪除了我的 GCP 項目的服務帳戶,而不是 Google 日歷 API 和 Dialogflow 服務帳戶的服務帳戶。

我現在在嘗試通過內聯代碼編輯器將我的對話流代理部署到 Cloud Functions 時遇到問題。 當我檢查日志時,我收到以下消息:

2020-07-30 15:48:40.350 WAT
Dialogflow API
CreateCloudFunction
us-central1
bashorun.emma@gmail.com
userFacingMessage: 
Default service account 'northern-timer-231210@appspot.gserviceaccount.com' doesn't exist. 
Please recreate this account (for example by disabling and enabling the Cloud Functions API),
or specify a different account.;
com.google.cloud.eventprocessing.manager.api.error.DefaultServiceAccountDoesNotExistException: userFacingMessage:
Default service account 'northern-timer-231210@appspot.gserviceaccount.com' doesn't exist. Please recreate this account (for example by disabling and enabling the Cloud Functions API), or specify a different account.; Code: FAILED_PRECONDITION com.google.apps.framework.request.StatusException: <eye3 title='FAILED_PRECONDITION'/> generic::FAILED_PRECONDITION: userFacingMessage:
Default service account 'northern-timer-231210@appspot.gserviceaccount.com' doesn't exist. 
Please recreate this account (for example by disabling and enabling the Cloud Functions API), or specify a different account.; com.google.cloud.eventprocessing.manager.api.error.DefaultServiceAccountDoesNotExistException: userFacingMessage: 
Default service account 'northern-timer-231210@appspot.gserviceaccount.com' doesn't exist. Please recreate this account (for example by disabling and enabling the Cloud Functions API), or specify a different account.; Code: FAILED_PRECONDITION

是否可以取回服務帳戶,或者我是否由於其他問題而收到這些錯誤?

服務帳號被刪除后,您可以在刪除后的 30 天內將其恢復

為此,您可以從雲 shell 運行以下命令

gcloud beta iam 服務帳戶取消刪除 ACCOUNT_ID

可以使用以下過濾器從堆棧驅動程序日志記錄中獲取帳戶 ID

resource.type="service_account" resource.labels.email_id="service-account-name" "DeleteServiceAccount"

希望這有助於恢復您的服務帳戶。

恢復 App Engine 或任何已刪除的服務帳戶

您可以取消刪除服務帳戶。 您將需要服務帳號的唯一 ID。 如果您沒有,可以在 Google Cloud Logging 上找到它。

您可以在側邊菜單中找到Logging服務:

谷歌日志,在哪里可以找到

然后,您將需要按日期過濾並鍵入service account以查找服務被刪除的確切時間。

Google Logging - 如何找到已刪除服務帳戶的唯一 ID

然后你可以

選項 1:使用 Google Cloud 命令行

您可以通過在計算機上安裝命令行來運行它( https://cloud.google.com/sdk/docs/install )。 或者您可以使用 Google Cloud Platform 提供的Active Shell在線運行它。

在哪里可以找到 Google Cloud Active Shell - gcloud

您要運行的命令如下。

gcloud beta iam service-accounts undelete 12345678901234567890

選項 2:使用谷歌雲 API

使用curl ,使用以下命令調用 API。

您需要將API_KEYPROJECT_IDSERVICE_ACCOUNT_UID更改為實際值。

curl -X POST \
-H "Authorization: Bearer API_KEY \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://iam.googleapis.com/v1/projects/PROJECT_ID/serviceAccounts/SERVICE_ACCOUNT_UID:undelete"

您可以從 Google Cloud 命令行獲取 API_KEY:

gcloud auth application-default print-access-token

同樣,您可以在本地計算機上安裝gcloud ,也可以通過Active Shell在線使用它。

在哪里可以找到 Google Cloud Active Shell - gcloud

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM