我试图遵循 Firebase 上的 Terraform 指南
但是我在 terraform apply 上进行 firebase 身份验证时总是遇到相同的错误
Error: Error creating Config: googleapi: Error 403: Your application is authenticating by using local Application Default Credentials. The identitytoolkit.googleapis.com API requires a quota project, which is not set by default. To learn how to set your quota project, see https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds .
│ Details:
│ [
│ {
│ "@type": "type.googleapis.com/google.rpc.ErrorInfo",
│ "domain": "googleapis.com",
│ "metadata": {
│ "consumer": "projects/1234567",
│ "service": "identitytoolkit.googleapis.com"
│ },
│ "reason": "SERVICE_DISABLED"
│ }
│ ]
│
│ with google_identity_platform_config.default,
│ on main.tf line 68, in resource "google_identity_platform_config" "default":
│ 68: resource "google_identity_platform_config" "default" {
在 firebase 中创建项目工作正常,还有像 firestore 这样的东西(我从本示例中排除),但身份验证不起作用。 错误消息看起来很清楚,但我在文档中找不到任何在 terraform 中“设置配额”的内容。
这是main.tf:
terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.84.0"
}
}
}
provider "google-beta" {
user_project_override = true
}
provider "google-beta" {
alias = "no_user_project_override"
user_project_override = false
}
resource "google_project" "default" {
provider = google-beta.no_user_project_override
name = "My Terraform Test"
project_id = "myterraformtest1"
billing_account = var.billing_account
labels = {
"firebase" = "enabled"
}
}
resource "google_project_service" "default" {
provider = google-beta.no_user_project_override
project = google_project.default.project_id
for_each = toset([
"cloudbilling.googleapis.com",
"cloudresourcemanager.googleapis.com",
"firebase.googleapis.com",
"serviceusage.googleapis.com",
"identitytoolkit.googleapis.com",
])
service = each.key
disable_on_destroy = false
}
resource "google_firebase_project" "default" {
provider = google-beta
project = google_project.default.project_id
depends_on = [
google_project_service.default
]
}
resource "google_identity_platform_config" "default" {
project = google_project.default.project_id
autodelete_anonymous_users = true
sign_in {
allow_duplicate_emails = true
email {
enabled = true
password_required = false
}
}
quota {
sign_up_quota_config {
quota = 1000
start_time = ""
quota_duration = "7200s"
}
}
authorized_domains = [
"localhost",
"${google_project.default.project_id}.firebaseapp.com",
"${google_project.default.project_id}.web.app",
]
depends_on = [google_project_service.default]
}
在我发现您的问题的地方添加了解决方案。 https://discuss.hashicorp.com/t/quota-error-in-terraform-firebase-authentication-identitytoolkit/66714/4。对我来说有效的是
provider "google-beta" {
project = var.project_id
billing_project = var.project_id
user_project_override = true
}
因为我正在使用测试版提供商。