A Google Cloud Firebase web application instance
To get more information about WebApp, see:
resource "google_firebase_web_app" "basic" {
provider = google-beta
project = "my-project-name"
display_name = "Display Name Basic"
}
data "google_firebase_web_app_config" "basic" {
provider = google-beta
web_app_id = google_firebase_web_app.basic.app_id
}
resource "google_storage_bucket" "default" {
provider = google-beta
name = "fb-webapp-"
location = "US"
}
resource "google_storage_bucket_object" "default" {
provider = google-beta
bucket = google_storage_bucket.default.name
name = "firebase-config.json"
content = jsonencode({
appId = google_firebase_web_app.basic.app_id
apiKey = data.google_firebase_web_app_config.basic.api_key
authDomain = data.google_firebase_web_app_config.basic.auth_domain
databaseURL = lookup(data.google_firebase_web_app_config.basic, "database_url", "")
storageBucket = lookup(data.google_firebase_web_app_config.basic, "storage_bucket", "")
messagingSenderId = lookup(data.google_firebase_web_app_config.basic, "messaging_sender_id", "")
measurementId = lookup(data.google_firebase_web_app_config.basic, "measurement_id", "")
})
}
resource "google_firebase_web_app" "default" {
provider = google-beta
project = "my-project-name"
display_name = "Display Name"
api_key_id = google_apikeys_key.web.uid
deletion_policy = "DELETE"
}
resource "google_apikeys_key" "web" {
provider = google-beta
project = "my-project-name"
name = "api-key"
display_name = "Display Name"
restrictions {
browser_key_restrictions {
allowed_referrers = ["*"]
}
}
}
The following arguments are supported:
display_name
-
(Required)
The user-assigned display name of the App.api_key_id
-
(Optional)
The globally unique, Google-assigned identifier (UID) for the Firebase API key associated with the WebApp.
If apiKeyId is not set during creation, then Firebase automatically associates an apiKeyId with the WebApp.
This auto-associated key may be an existing valid key or, if no valid key exists, a new one will be provisioned.
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
deletion_policy
- (Optional) Set to ABANDON
to allow the WebApp to be untracked from terraform state
rather than deleted upon terraform destroy
. This is useful becaue the WebApp may be
serving traffic. Set to DELETE
to delete the WebApp. Default to DELETE
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format projects/{{project}}/webApps/{{app_id}}
name
-
The fully qualified resource name of the App, for example:
projects/projectId/webApps/appId
app_id
-
The globally unique, Firebase-assigned identifier of the App.
This identifier should be treated as an opaque token, as the data format is not specified.
app_urls
-
The URLs where the WebApp
is hosted.
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.WebApp can be imported using any of these accepted formats:
{{project}} projects/{{project}}/webApps/{{app_id}}
projects/{{project}}/webApps/{{app_id}}
{{project}}/{{project}}/{{app_id}}
webApps/{{app_id}}
{{app_id}}
In Terraform v1.5.0 and later, use an import
block to import WebApp using one of the formats above. For example:
import {
id = "{{project}} projects/{{project}}/webApps/{{app_id}}"
to = google_firebase_web_app.default
}
When using the terraform import
command, WebApp can be imported using one of the formats above. For example:
$ terraform import google_firebase_web_app.default {{project}} projects/{{project}}/webApps/{{app_id}}
$ terraform import google_firebase_web_app.default projects/{{project}}/webApps/{{app_id}}
$ terraform import google_firebase_web_app.default {{project}}/{{project}}/{{app_id}}
$ terraform import google_firebase_web_app.default webApps/{{app_id}}
$ terraform import google_firebase_web_app.default {{app_id}}
This resource supports User Project Overrides.