google_firebase_hosting_custom_domain

Manages Custom Domains for Firebase Hosting. Custom Domains link your domain names with Firebase Hosting sites, allowing Hosting to serve content on those domain names.

To get more information about CustomDomain, see:

Example Usage - Firebasehosting Customdomain Basic

resource "google_firebase_hosting_custom_domain" "default" {
  provider = google-beta

  project  = "my-project-name"
  site_id = "site-id"
  custom_domain = "custom.domain.com"
}

Example Usage - Firebasehosting Customdomain Full

resource "google_firebase_hosting_site" "default" {
  provider = google-beta
  project  = "my-project-name"

  site_id = "site-id-full"
}

resource "google_firebase_hosting_custom_domain" "default" {
  provider = google-beta

  project  = "my-project-name"
  site_id = google_firebase_hosting_site.default.site_id
  custom_domain = "source.domain.com"
  cert_preference = "GROUPED"
  redirect_target = "destination.domain.com"

  wait_dns_verification = false
}

Example Usage - Firebasehosting Customdomain Cloud Run

resource "google_firebase_hosting_site" "default" {
  provider = google-beta
  project  = "my-project-name"
  site_id  = "site-id"
}

resource "google_cloud_run_v2_service" "default" {
  provider = google-beta
  project  = "my-project-name"
  name     = "cloud-run-service-via-hosting"
  location = "us-central1"

  # Warning: allows all public traffic
  ingress = "INGRESS_TRAFFIC_ALL"

  template {
    containers {
      image = "us-docker.pkg.dev/cloudrun/container/hello"
    }
  }
}

resource "google_firebase_hosting_version" "default" {
  provider = google-beta
  site_id  = google_firebase_hosting_site.default.site_id
  config {
    rewrites {
      glob = "/hello/**"
      run {
        service_id = google_cloud_run_v2_service.default.name
        region = google_cloud_run_v2_service.default.location
      }
    }
  }
}

resource "google_firebase_hosting_release" "default" {
  provider     = google-beta
  site_id      = google_firebase_hosting_site.default.site_id
  version_name = google_firebase_hosting_version.default.name
  message      = "Cloud Run Integration"
}

resource "google_firebase_hosting_custom_domain" "default" {
  provider = google-beta

  project  = "my-project-name"
  site_id  = google_firebase_hosting_site.default.site_id
  custom_domain = "run.custom.domain.com"

  wait_dns_verification = false
}

Argument Reference

The following arguments are supported:


Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

The required_dns_updates block contains:

The discovered block supports:

The records block supports:

The desired block supports:

The records block supports:

The issues block contains:

The cert block contains:

The verification block supports:

The dns block supports:

The discovered block supports:

The records block supports:

The desired block supports:

The records block supports:

The http block supports:

Timeouts

This resource provides the following Timeouts configuration options:

Import

CustomDomain can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import CustomDomain using one of the formats above. For example:

import {
  id = "projects/{{project}}/sites/{{site_id}}/customDomains/{{custom_domain}}"
  to = google_firebase_hosting_custom_domain.default
}

When using the terraform import command, CustomDomain can be imported using one of the formats above. For example:

$ terraform import google_firebase_hosting_custom_domain.default projects/{{project}}/sites/{{site_id}}/customDomains/{{custom_domain}}
$ terraform import google_firebase_hosting_custom_domain.default sites/{{site_id}}/customDomains/{{custom_domain}}
$ terraform import google_firebase_hosting_custom_domain.default {{project}}/{{site_id}}/{{custom_domain}}
$ terraform import google_firebase_hosting_custom_domain.default {{site_id}}/{{custom_domain}}

User Project Overrides

This resource supports User Project Overrides.