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 depend on an existing Firebase App Hosting backend, which requires a service account and Firebase web app. The examples are intentionally small. Combine them with your own backend configuration and project settings.
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
The backend property links the domain to your App Hosting backend. The domainId follows the format {{backend}}--{{project_id}}.{{location}}.hosted.app, which Firebase generates automatically. The domain becomes active immediately, routing requests to your backend.
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 stops the domain from serving traffic while preserving its configuration. This is useful during maintenance windows or when transitioning to custom domains. Set it back to false to resume serving traffic.
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 require pre-existing infrastructure such as Firebase App Hosting backend, service account for backend compute, and Firebase web app (appId). They focus on domain configuration rather than provisioning the backend infrastructure.
To keep things focused, common domain 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 FREEFrequently Asked Questions
Configuration & Setup
AppHostingBackend resource. All examples show the domain referencing the backend’s project, location, backendId, and uri properties.{{backend}}--{{project_id}}.{{location}}.hosted.app. In practice, you can reference the backend’s uri property as shown in the examples.Domain Management
backend, domainId, location, and project properties are immutable and cannot be modified after creation.disabled property defaults to false.disabled property to true when creating or updating the domain.Using a different cloud?
Explore networking guides for other cloud providers: