简体   繁体   English

如何恢复 GCP 项目服务帐号

[英]How to recover GCP project service account

I ignorantly deleted the service account to my GCP project rather than the service account to Google Calendar API and Dialogflow service account.我无知地删除了我的 GCP 项目的服务帐户,而不是 Google 日历 API 和 Dialogflow 服务帐户的服务帐户。

I'm now having issues trying to deploy my dialogflow agent through the inline code editor to Cloud Functions.我现在在尝试通过内联代码编辑器将我的对话流代理部署到 Cloud Functions 时遇到问题。 When I check the logs, I get this message:当我检查日志时,我收到以下消息:

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

Is it possible to retrieve back the service account or am I getting these errors as a result of a different problem?是否可以取回服务帐户,或者我是否由于其他问题而收到这些错误?

After a service account is deleted, you can recover it between 30 days after its deletion.服务帐号被删除后,您可以在删除后的 30 天内将其恢复

To do it, you can run the following command from cloud shell:为此,您可以从云 shell 运行以下命令

gcloud beta iam service-accounts undelete ACCOUNT_ID gcloud beta iam 服务帐户取消删除 ACCOUNT_ID

The account ID can be taken from stackdriver logging with the following filter可以使用以下过滤器从堆栈驱动程序日志记录中获取帐户 ID

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

Hope this helps to recover your service account.希望这有助于恢复您的服务帐户。

Recover App Engine or any deleted service account恢复 App Engine 或任何已删除的服务帐户

You can undelete service accounts.您可以取消删除服务帐户。 You will need the service account's unique ID.您将需要服务帐号的唯一 ID。 If you don't have it, you can find it on Google Cloud Logging.如果您没有,可以在 Google Cloud Logging 上找到它。

You can find Logging service here on the side menu:您可以在侧边菜单中找到Logging服务:

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

Then you will need to filter by date and type service account to find the exact moment the service was deleted.然后,您将需要按日期过滤并键入service account以查找服务被删除的确切时间。

Google Logging - 如何找到已删除服务帐户的唯一 ID

Then you can either然后你可以

Option 1: Use Google Cloud Command Line选项 1:使用 Google Cloud 命令行

You can run the command line by installing it on your computer ( https://cloud.google.com/sdk/docs/install ).您可以通过在计算机上安装命令行来运行它( https://cloud.google.com/sdk/docs/install )。 Or you can run it online using the Active Shell offered by Google Cloud Platform.或者您可以使用 Google Cloud Platform 提供的Active Shell在线运行它。

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

The command you want to run is the following.您要运行的命令如下。

gcloud beta iam service-accounts undelete 12345678901234567890

Option 2: Use Google Cloud API选项 2:使用谷歌云 API

Using curl , call the API with the following command.使用curl ,使用以下命令调用 API。

You will need to change API_KEY , PROJECT_ID and SERVICE_ACCOUNT_UID for real values.您需要将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"

You can get the API_KEY from Google Cloud Command Line:您可以从 Google Cloud 命令行获取 API_KEY:

gcloud auth application-default print-access-token

Again you can either have gcloud installed on your local machine or you can use it online with the Active Shell .同样,您可以在本地计算机上安装gcloud ,也可以通过Active Shell在线使用它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 GCP 中使用服务帐号创建项目 - Create project with service account in GCP 如何将 Dialogflow CX 代理链接到 GCP 项目服务帐户? - How to link Dialogflow CX agent to GCP Project Service Account? 在 GCP 上,如何授予对另一个项目中服务帐户的访问权限? - On GCP, how to grant access to a service account in another project? 如何将GCP服务帐户添加到Kubernetes工作负载/项目 - How To Add GCP Service Account To Kubernetes Workload/Project 服务帐号的 GCP 项目配额问题 - GCP project quota issue with service account 具有项目所有者的 GCP 服务帐户可以授予用户帐户权限吗? - Can a GCP service account with owner for a project grant rights to user account? 使用服务帐号将 GCP 项目关联到结算帐号 - Link a GCP project to a billing account using a service account 如何将 GCP IAM 角色添加到服务帐号 - How to add GCP IAM roles to Service Account 如何使用服务帐户文件向GCP API进行身份验证 - How to authenticate to GCP API with service account file 如何通过 API 获取服务帐户对 GCP 中项目和组织的所有角色/权限 - How to get all roles/permissions that a service account have for a project and organization in GCP through API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM