Configure GCP Firebase App Hosting Default Domains

The gcp:firebase/appHostingDefaultDomain:AppHostingDefaultDomain resource, part of the Pulumi GCP provider, associates a default domain with a Firebase App Hosting backend, providing an automatically-generated URL for serving traffic. This guide focuses on two capabilities: default domain creation and traffic control via the disabled flag.

Default domains belong to App Hosting backends and use the backend’s URI to generate the domain ID. The examples are intentionally small. Combine them with your own backend configuration and service accounts.

Associate a default domain with a backend

Firebase App Hosting backends need a domain to serve traffic. The default domain provides an automatically-generated URL without requiring custom DNS configuration.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const serviceAccount = new gcp.serviceaccount.Account("service_account", {
    project: "my-project-name",
    accountId: "service-account",
    displayName: "Firebase App Hosting compute service account",
    createIgnoreAlreadyExists: true,
});
const exampleAppHostingBackend = new gcp.firebase.AppHostingBackend("example", {
    project: "my-project-name",
    location: "us-central1",
    backendId: "dd-mini",
    appId: "1:0000000000:web:674cde32020e16fbce9dbd",
    servingLocality: "GLOBAL_ACCESS",
    serviceAccount: serviceAccount.email,
});
const example = new gcp.firebase.AppHostingDefaultDomain("example", {
    project: exampleAppHostingBackend.project,
    location: exampleAppHostingBackend.location,
    backend: exampleAppHostingBackend.backendId,
    domainId: exampleAppHostingBackend.uri,
});
import pulumi
import pulumi_gcp as gcp

service_account = gcp.serviceaccount.Account("service_account",
    project="my-project-name",
    account_id="service-account",
    display_name="Firebase App Hosting compute service account",
    create_ignore_already_exists=True)
example_app_hosting_backend = gcp.firebase.AppHostingBackend("example",
    project="my-project-name",
    location="us-central1",
    backend_id="dd-mini",
    app_id="1:0000000000:web:674cde32020e16fbce9dbd",
    serving_locality="GLOBAL_ACCESS",
    service_account=service_account.email)
example = gcp.firebase.AppHostingDefaultDomain("example",
    project=example_app_hosting_backend.project,
    location=example_app_hosting_backend.location,
    backend=example_app_hosting_backend.backend_id,
    domain_id=example_app_hosting_backend.uri)
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/firebase"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/serviceaccount"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		serviceAccount, err := serviceaccount.NewAccount(ctx, "service_account", &serviceaccount.AccountArgs{
			Project:                   pulumi.String("my-project-name"),
			AccountId:                 pulumi.String("service-account"),
			DisplayName:               pulumi.String("Firebase App Hosting compute service account"),
			CreateIgnoreAlreadyExists: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		exampleAppHostingBackend, err := firebase.NewAppHostingBackend(ctx, "example", &firebase.AppHostingBackendArgs{
			Project:         pulumi.String("my-project-name"),
			Location:        pulumi.String("us-central1"),
			BackendId:       pulumi.String("dd-mini"),
			AppId:           pulumi.String("1:0000000000:web:674cde32020e16fbce9dbd"),
			ServingLocality: pulumi.String("GLOBAL_ACCESS"),
			ServiceAccount:  serviceAccount.Email,
		})
		if err != nil {
			return err
		}
		_, err = firebase.NewAppHostingDefaultDomain(ctx, "example", &firebase.AppHostingDefaultDomainArgs{
			Project:  exampleAppHostingBackend.Project,
			Location: exampleAppHostingBackend.Location,
			Backend:  exampleAppHostingBackend.BackendId,
			DomainId: exampleAppHostingBackend.Uri,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var serviceAccount = new Gcp.ServiceAccount.Account("service_account", new()
    {
        Project = "my-project-name",
        AccountId = "service-account",
        DisplayName = "Firebase App Hosting compute service account",
        CreateIgnoreAlreadyExists = true,
    });

    var exampleAppHostingBackend = new Gcp.Firebase.AppHostingBackend("example", new()
    {
        Project = "my-project-name",
        Location = "us-central1",
        BackendId = "dd-mini",
        AppId = "1:0000000000:web:674cde32020e16fbce9dbd",
        ServingLocality = "GLOBAL_ACCESS",
        ServiceAccount = serviceAccount.Email,
    });

    var example = new Gcp.Firebase.AppHostingDefaultDomain("example", new()
    {
        Project = exampleAppHostingBackend.Project,
        Location = exampleAppHostingBackend.Location,
        Backend = exampleAppHostingBackend.BackendId,
        DomainId = exampleAppHostingBackend.Uri,
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.serviceaccount.Account;
import com.pulumi.gcp.serviceaccount.AccountArgs;
import com.pulumi.gcp.firebase.AppHostingBackend;
import com.pulumi.gcp.firebase.AppHostingBackendArgs;
import com.pulumi.gcp.firebase.AppHostingDefaultDomain;
import com.pulumi.gcp.firebase.AppHostingDefaultDomainArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var serviceAccount = new Account("serviceAccount", AccountArgs.builder()
            .project("my-project-name")
            .accountId("service-account")
            .displayName("Firebase App Hosting compute service account")
            .createIgnoreAlreadyExists(true)
            .build());

        var exampleAppHostingBackend = new AppHostingBackend("exampleAppHostingBackend", AppHostingBackendArgs.builder()
            .project("my-project-name")
            .location("us-central1")
            .backendId("dd-mini")
            .appId("1:0000000000:web:674cde32020e16fbce9dbd")
            .servingLocality("GLOBAL_ACCESS")
            .serviceAccount(serviceAccount.email())
            .build());

        var example = new AppHostingDefaultDomain("example", AppHostingDefaultDomainArgs.builder()
            .project(exampleAppHostingBackend.project())
            .location(exampleAppHostingBackend.location())
            .backend(exampleAppHostingBackend.backendId())
            .domainId(exampleAppHostingBackend.uri())
            .build());

    }
}
resources:
  example:
    type: gcp:firebase:AppHostingDefaultDomain
    properties:
      project: ${exampleAppHostingBackend.project}
      location: ${exampleAppHostingBackend.location}
      backend: ${exampleAppHostingBackend.backendId}
      domainId: ${exampleAppHostingBackend.uri}
  exampleAppHostingBackend:
    type: gcp:firebase:AppHostingBackend
    name: example
    properties:
      project: my-project-name
      location: us-central1
      backendId: dd-mini
      appId: 1:0000000000:web:674cde32020e16fbce9dbd
      servingLocality: GLOBAL_ACCESS
      serviceAccount: ${serviceAccount.email}
  serviceAccount:
    type: gcp:serviceaccount:Account
    name: service_account
    properties:
      project: my-project-name
      accountId: service-account
      displayName: Firebase App Hosting compute service account
      createIgnoreAlreadyExists: true

When you create a default domain, Firebase generates a URL in the format backend--project.location.hosted.app. The domainId property must match the backend’s URI. The backend, project, and location properties link the domain to its parent backend resource. Traffic flows to the backend immediately unless you set disabled to true.

Disable traffic to a default domain

When migrating to a custom domain or temporarily suspending a backend, you can disable the default domain without deleting it.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const serviceAccount = new gcp.serviceaccount.Account("service_account", {
    project: "my-project-name",
    accountId: "service-account",
    displayName: "Firebase App Hosting compute service account",
    createIgnoreAlreadyExists: true,
});
const exampleAppHostingBackend = new gcp.firebase.AppHostingBackend("example", {
    project: "my-project-name",
    location: "us-central1",
    backendId: "dd-disabled",
    appId: "1:0000000000:web:674cde32020e16fbce9dbd",
    servingLocality: "GLOBAL_ACCESS",
    serviceAccount: serviceAccount.email,
});
const example = new gcp.firebase.AppHostingDefaultDomain("example", {
    project: exampleAppHostingBackend.project,
    location: exampleAppHostingBackend.location,
    backend: exampleAppHostingBackend.backendId,
    domainId: exampleAppHostingBackend.uri,
    disabled: true,
});
import pulumi
import pulumi_gcp as gcp

service_account = gcp.serviceaccount.Account("service_account",
    project="my-project-name",
    account_id="service-account",
    display_name="Firebase App Hosting compute service account",
    create_ignore_already_exists=True)
example_app_hosting_backend = gcp.firebase.AppHostingBackend("example",
    project="my-project-name",
    location="us-central1",
    backend_id="dd-disabled",
    app_id="1:0000000000:web:674cde32020e16fbce9dbd",
    serving_locality="GLOBAL_ACCESS",
    service_account=service_account.email)
example = gcp.firebase.AppHostingDefaultDomain("example",
    project=example_app_hosting_backend.project,
    location=example_app_hosting_backend.location,
    backend=example_app_hosting_backend.backend_id,
    domain_id=example_app_hosting_backend.uri,
    disabled=True)
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/firebase"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/serviceaccount"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		serviceAccount, err := serviceaccount.NewAccount(ctx, "service_account", &serviceaccount.AccountArgs{
			Project:                   pulumi.String("my-project-name"),
			AccountId:                 pulumi.String("service-account"),
			DisplayName:               pulumi.String("Firebase App Hosting compute service account"),
			CreateIgnoreAlreadyExists: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		exampleAppHostingBackend, err := firebase.NewAppHostingBackend(ctx, "example", &firebase.AppHostingBackendArgs{
			Project:         pulumi.String("my-project-name"),
			Location:        pulumi.String("us-central1"),
			BackendId:       pulumi.String("dd-disabled"),
			AppId:           pulumi.String("1:0000000000:web:674cde32020e16fbce9dbd"),
			ServingLocality: pulumi.String("GLOBAL_ACCESS"),
			ServiceAccount:  serviceAccount.Email,
		})
		if err != nil {
			return err
		}
		_, err = firebase.NewAppHostingDefaultDomain(ctx, "example", &firebase.AppHostingDefaultDomainArgs{
			Project:  exampleAppHostingBackend.Project,
			Location: exampleAppHostingBackend.Location,
			Backend:  exampleAppHostingBackend.BackendId,
			DomainId: exampleAppHostingBackend.Uri,
			Disabled: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var serviceAccount = new Gcp.ServiceAccount.Account("service_account", new()
    {
        Project = "my-project-name",
        AccountId = "service-account",
        DisplayName = "Firebase App Hosting compute service account",
        CreateIgnoreAlreadyExists = true,
    });

    var exampleAppHostingBackend = new Gcp.Firebase.AppHostingBackend("example", new()
    {
        Project = "my-project-name",
        Location = "us-central1",
        BackendId = "dd-disabled",
        AppId = "1:0000000000:web:674cde32020e16fbce9dbd",
        ServingLocality = "GLOBAL_ACCESS",
        ServiceAccount = serviceAccount.Email,
    });

    var example = new Gcp.Firebase.AppHostingDefaultDomain("example", new()
    {
        Project = exampleAppHostingBackend.Project,
        Location = exampleAppHostingBackend.Location,
        Backend = exampleAppHostingBackend.BackendId,
        DomainId = exampleAppHostingBackend.Uri,
        Disabled = true,
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.serviceaccount.Account;
import com.pulumi.gcp.serviceaccount.AccountArgs;
import com.pulumi.gcp.firebase.AppHostingBackend;
import com.pulumi.gcp.firebase.AppHostingBackendArgs;
import com.pulumi.gcp.firebase.AppHostingDefaultDomain;
import com.pulumi.gcp.firebase.AppHostingDefaultDomainArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var serviceAccount = new Account("serviceAccount", AccountArgs.builder()
            .project("my-project-name")
            .accountId("service-account")
            .displayName("Firebase App Hosting compute service account")
            .createIgnoreAlreadyExists(true)
            .build());

        var exampleAppHostingBackend = new AppHostingBackend("exampleAppHostingBackend", AppHostingBackendArgs.builder()
            .project("my-project-name")
            .location("us-central1")
            .backendId("dd-disabled")
            .appId("1:0000000000:web:674cde32020e16fbce9dbd")
            .servingLocality("GLOBAL_ACCESS")
            .serviceAccount(serviceAccount.email())
            .build());

        var example = new AppHostingDefaultDomain("example", AppHostingDefaultDomainArgs.builder()
            .project(exampleAppHostingBackend.project())
            .location(exampleAppHostingBackend.location())
            .backend(exampleAppHostingBackend.backendId())
            .domainId(exampleAppHostingBackend.uri())
            .disabled(true)
            .build());

    }
}
resources:
  example:
    type: gcp:firebase:AppHostingDefaultDomain
    properties:
      project: ${exampleAppHostingBackend.project}
      location: ${exampleAppHostingBackend.location}
      backend: ${exampleAppHostingBackend.backendId}
      domainId: ${exampleAppHostingBackend.uri}
      disabled: true
  exampleAppHostingBackend:
    type: gcp:firebase:AppHostingBackend
    name: example
    properties:
      project: my-project-name
      location: us-central1
      backendId: dd-disabled
      appId: 1:0000000000:web:674cde32020e16fbce9dbd
      servingLocality: GLOBAL_ACCESS
      serviceAccount: ${serviceAccount.email}
  serviceAccount:
    type: gcp:serviceaccount:Account
    name: service_account
    properties:
      project: my-project-name
      accountId: service-account
      displayName: Firebase App Hosting compute service account
      createIgnoreAlreadyExists: true

Setting disabled to true prevents traffic from reaching the backend via the default domain. The domain resource remains in place, preserving its configuration. Set disabled to false to re-enable traffic without recreating the domain.

Beyond these examples

These snippets focus on specific default domain features: default domain association and traffic control via disabled flag. They’re intentionally minimal rather than full hosting configurations.

The examples reference pre-existing infrastructure such as Firebase App Hosting backend, service account for backend compute, and Firebase web app ID. They focus on domain configuration rather than provisioning the backend itself.

To keep things focused, domain-related patterns are omitted, including:

  • Custom domain configuration (separate resource)
  • SSL certificate management
  • Domain verification workflows

These omissions are intentional: the goal is to illustrate how default domain features are wired, not provide drop-in hosting modules. See the Firebase App Hosting Default Domain resource reference for all available configuration options.

Let's configure GCP Firebase App Hosting Default Domains

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Domain Configuration
What's the required format for domainId?
For default domains, use the format {{backend}}--{{project_id}}.{{location}}.hosted.app. All examples show setting domainId to the backend’s uri property.
How do I connect a domain to an App Hosting backend?
Reference the backend’s properties when creating the domain: set project to backend.project, location to backend.location, backend to backend.backendId, and domainId to backend.uri.
Managing Domains
What properties can't I change after creating a domain?
The backend, domainId, location, and project properties are immutable. Changing any of these requires replacing the resource.
How do I disable or enable a domain?
Set the disabled property to true to disable or false to enable. Domains are enabled by default (disabled defaults to false).

Using a different cloud?

Explore networking guides for other cloud providers: