【问题标题】:Import of existing Firebase Project into Terraform State receiving 403 error将现有 Firebase 项目导入 Terraform 状态接收 403 错误
【发布时间】:2020-11-11 19:13:23
【问题描述】:

在将现有基础架构迁移到“基础架构即代码”设置时,我们还需要导入现有 Firebase 项目。

按照GCP beta Terraform provider 的说明进行操作。在对应的terraform模块中添加了以下sn-p。

resource "google_firebase_project" "default" {
  provider = google-beta
  project = "my-project-id"
}

通过运行命令启动现有 Firebase 项目的导入

terraform import google_firebase_project.default my-project-id

这导致了以下输出:

google_firebase_project.default: Importing from ID "my-project-id"...
google_firebase_project.default: Import prepared!
  Prepared google_firebase_project for import
google_firebase_project.default: Refreshing state... [id=projects/my-project-id]
Error: Error when reading or editing FirebaseProject "projects/my-project-id": googleapi: Error 403: Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the firebase.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.

错误是在使用服务帐户运行 Terraform 或使用最终用户帐户模拟服务帐户时获得的。所有身份都拥有相应 GCP 项目的 Owner 权限。

【问题讨论】:

  • 您好,您遇到过解决方案吗?我也遇到了 firebase api 的凭据错误。
  • 不,我们已经在我们组织的新项目中删除了 Firebase 的使用,因为 API 不足以作为成熟的代码软件交付工作流。如果您具备良好的 terraform 技能,则可以从 GCP 原生资源中获得相同的技能,而无需更少的技术债务和更多的可能性。

标签: firebase google-cloud-platform terraform


【解决方案1】:

您的错误消息与您对 firebase terraform 资源的使用没有直接关系,而是与您无法与人类用户与 firebase API 交谈这一事实有关。相反,您应该创建一个服务帐户,例如称为terraform,授予它创建firebase资源所需的权限,并授予您的用户模拟服务帐户的权限。

那么你需要像这样配置你的 GCP 提供者

provider "google" {
  impersonate_service_account = "terraform@my-gcp-project.iam.gserviceaccount.com"
}

provider "google-beta" {
  impersonate_service_account = "terraform@my-gcp-project.iam.gserviceaccount.com"
}

建议在共享项目中创建单个 terraform 服务帐户,并使用它通过 terraform 创建所有其他资源。有关此模式,另请参阅 https://github.com/terraform-google-modules/terraform-google-bootstrap

【讨论】:

  • 最初发布问题时,此解决方案不存在。但我认为它解决了它。?
猜你喜欢
  • 2023-03-18
  • 2021-05-25
  • 1970-01-01
  • 2021-10-08
  • 2023-03-08
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 2016-08-08
相关资源
最近更新 更多