gcp.firebase.HostingVersion
Explore with Pulumi AI
Example Usage
Firebasehosting Version Redirect
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.firebase.HostingSite("default", {
project: "my-project-name",
siteId: "site-id",
});
const defaultHostingVersion = new gcp.firebase.HostingVersion("default", {
siteId: _default.siteId,
config: {
redirects: [{
glob: "/google/**",
statusCode: 302,
location: "https://www.google.com",
}],
},
});
const defaultHostingRelease = new gcp.firebase.HostingRelease("default", {
siteId: _default.siteId,
versionName: defaultHostingVersion.name,
message: "Redirect to Google",
});
import pulumi
import pulumi_gcp as gcp
default = gcp.firebase.HostingSite("default",
project="my-project-name",
site_id="site-id")
default_hosting_version = gcp.firebase.HostingVersion("default",
site_id=default.site_id,
config={
"redirects": [{
"glob": "/google/**",
"status_code": 302,
"location": "https://www.google.com",
}],
})
default_hosting_release = gcp.firebase.HostingRelease("default",
site_id=default.site_id,
version_name=default_hosting_version.name,
message="Redirect to Google")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/firebase"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := firebase.NewHostingSite(ctx, "default", &firebase.HostingSiteArgs{
Project: pulumi.String("my-project-name"),
SiteId: pulumi.String("site-id"),
})
if err != nil {
return err
}
defaultHostingVersion, err := firebase.NewHostingVersion(ctx, "default", &firebase.HostingVersionArgs{
SiteId: _default.SiteId,
Config: &firebase.HostingVersionConfigArgs{
Redirects: firebase.HostingVersionConfigRedirectArray{
&firebase.HostingVersionConfigRedirectArgs{
Glob: pulumi.String("/google/**"),
StatusCode: pulumi.Int(302),
Location: pulumi.String("https://www.google.com"),
},
},
},
})
if err != nil {
return err
}
_, err = firebase.NewHostingRelease(ctx, "default", &firebase.HostingReleaseArgs{
SiteId: _default.SiteId,
VersionName: defaultHostingVersion.Name,
Message: pulumi.String("Redirect to Google"),
})
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 @default = new Gcp.Firebase.HostingSite("default", new()
{
Project = "my-project-name",
SiteId = "site-id",
});
var defaultHostingVersion = new Gcp.Firebase.HostingVersion("default", new()
{
SiteId = @default.SiteId,
Config = new Gcp.Firebase.Inputs.HostingVersionConfigArgs
{
Redirects = new[]
{
new Gcp.Firebase.Inputs.HostingVersionConfigRedirectArgs
{
Glob = "/google/**",
StatusCode = 302,
Location = "https://www.google.com",
},
},
},
});
var defaultHostingRelease = new Gcp.Firebase.HostingRelease("default", new()
{
SiteId = @default.SiteId,
VersionName = defaultHostingVersion.Name,
Message = "Redirect to Google",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firebase.HostingSite;
import com.pulumi.gcp.firebase.HostingSiteArgs;
import com.pulumi.gcp.firebase.HostingVersion;
import com.pulumi.gcp.firebase.HostingVersionArgs;
import com.pulumi.gcp.firebase.inputs.HostingVersionConfigArgs;
import com.pulumi.gcp.firebase.HostingRelease;
import com.pulumi.gcp.firebase.HostingReleaseArgs;
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 default_ = new HostingSite("default", HostingSiteArgs.builder()
.project("my-project-name")
.siteId("site-id")
.build());
var defaultHostingVersion = new HostingVersion("defaultHostingVersion", HostingVersionArgs.builder()
.siteId(default_.siteId())
.config(HostingVersionConfigArgs.builder()
.redirects(HostingVersionConfigRedirectArgs.builder()
.glob("/google/**")
.statusCode(302)
.location("https://www.google.com")
.build())
.build())
.build());
var defaultHostingRelease = new HostingRelease("defaultHostingRelease", HostingReleaseArgs.builder()
.siteId(default_.siteId())
.versionName(defaultHostingVersion.name())
.message("Redirect to Google")
.build());
}
}
resources:
default:
type: gcp:firebase:HostingSite
properties:
project: my-project-name
siteId: site-id
defaultHostingVersion:
type: gcp:firebase:HostingVersion
name: default
properties:
siteId: ${default.siteId}
config:
redirects:
- glob: /google/**
statusCode: 302
location: https://www.google.com
defaultHostingRelease:
type: gcp:firebase:HostingRelease
name: default
properties:
siteId: ${default.siteId}
versionName: ${defaultHostingVersion.name}
message: Redirect to Google
Firebasehosting Version Path
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.firebase.HostingSite("default", {
project: "my-project-name",
siteId: "site-id",
});
const defaultHostingVersion = new gcp.firebase.HostingVersion("default", {
siteId: _default.siteId,
config: {
rewrites: [{
glob: "**",
path: "/index.html",
}],
},
});
const defaultHostingRelease = new gcp.firebase.HostingRelease("default", {
siteId: _default.siteId,
versionName: defaultHostingVersion.name,
message: "Path Rewrite",
});
import pulumi
import pulumi_gcp as gcp
default = gcp.firebase.HostingSite("default",
project="my-project-name",
site_id="site-id")
default_hosting_version = gcp.firebase.HostingVersion("default",
site_id=default.site_id,
config={
"rewrites": [{
"glob": "**",
"path": "/index.html",
}],
})
default_hosting_release = gcp.firebase.HostingRelease("default",
site_id=default.site_id,
version_name=default_hosting_version.name,
message="Path Rewrite")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/firebase"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := firebase.NewHostingSite(ctx, "default", &firebase.HostingSiteArgs{
Project: pulumi.String("my-project-name"),
SiteId: pulumi.String("site-id"),
})
if err != nil {
return err
}
defaultHostingVersion, err := firebase.NewHostingVersion(ctx, "default", &firebase.HostingVersionArgs{
SiteId: _default.SiteId,
Config: &firebase.HostingVersionConfigArgs{
Rewrites: firebase.HostingVersionConfigRewriteArray{
&firebase.HostingVersionConfigRewriteArgs{
Glob: pulumi.String("**"),
Path: pulumi.String("/index.html"),
},
},
},
})
if err != nil {
return err
}
_, err = firebase.NewHostingRelease(ctx, "default", &firebase.HostingReleaseArgs{
SiteId: _default.SiteId,
VersionName: defaultHostingVersion.Name,
Message: pulumi.String("Path Rewrite"),
})
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 @default = new Gcp.Firebase.HostingSite("default", new()
{
Project = "my-project-name",
SiteId = "site-id",
});
var defaultHostingVersion = new Gcp.Firebase.HostingVersion("default", new()
{
SiteId = @default.SiteId,
Config = new Gcp.Firebase.Inputs.HostingVersionConfigArgs
{
Rewrites = new[]
{
new Gcp.Firebase.Inputs.HostingVersionConfigRewriteArgs
{
Glob = "**",
Path = "/index.html",
},
},
},
});
var defaultHostingRelease = new Gcp.Firebase.HostingRelease("default", new()
{
SiteId = @default.SiteId,
VersionName = defaultHostingVersion.Name,
Message = "Path Rewrite",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firebase.HostingSite;
import com.pulumi.gcp.firebase.HostingSiteArgs;
import com.pulumi.gcp.firebase.HostingVersion;
import com.pulumi.gcp.firebase.HostingVersionArgs;
import com.pulumi.gcp.firebase.inputs.HostingVersionConfigArgs;
import com.pulumi.gcp.firebase.HostingRelease;
import com.pulumi.gcp.firebase.HostingReleaseArgs;
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 default_ = new HostingSite("default", HostingSiteArgs.builder()
.project("my-project-name")
.siteId("site-id")
.build());
var defaultHostingVersion = new HostingVersion("defaultHostingVersion", HostingVersionArgs.builder()
.siteId(default_.siteId())
.config(HostingVersionConfigArgs.builder()
.rewrites(HostingVersionConfigRewriteArgs.builder()
.glob("**")
.path("/index.html")
.build())
.build())
.build());
var defaultHostingRelease = new HostingRelease("defaultHostingRelease", HostingReleaseArgs.builder()
.siteId(default_.siteId())
.versionName(defaultHostingVersion.name())
.message("Path Rewrite")
.build());
}
}
resources:
default:
type: gcp:firebase:HostingSite
properties:
project: my-project-name
siteId: site-id
defaultHostingVersion:
type: gcp:firebase:HostingVersion
name: default
properties:
siteId: ${default.siteId}
config:
rewrites:
- glob: '**'
path: /index.html
defaultHostingRelease:
type: gcp:firebase:HostingRelease
name: default
properties:
siteId: ${default.siteId}
versionName: ${defaultHostingVersion.name}
message: Path Rewrite
Firebasehosting Version Cloud Run
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.firebase.HostingSite("default", {
project: "my-project-name",
siteId: "site-id",
});
const defaultService = new gcp.cloudrunv2.Service("default", {
project: "my-project-name",
name: "cloud-run-service-via-hosting",
location: "us-central1",
ingress: "INGRESS_TRAFFIC_ALL",
template: {
containers: [{
image: "us-docker.pkg.dev/cloudrun/container/hello",
}],
},
deletionProtection: true,
});
const defaultHostingVersion = new gcp.firebase.HostingVersion("default", {
siteId: _default.siteId,
config: {
rewrites: [{
glob: "/hello/**",
run: {
serviceId: defaultService.name,
region: defaultService.location,
},
}],
},
});
const defaultHostingRelease = new gcp.firebase.HostingRelease("default", {
siteId: _default.siteId,
versionName: defaultHostingVersion.name,
message: "Cloud Run Integration",
});
import pulumi
import pulumi_gcp as gcp
default = gcp.firebase.HostingSite("default",
project="my-project-name",
site_id="site-id")
default_service = gcp.cloudrunv2.Service("default",
project="my-project-name",
name="cloud-run-service-via-hosting",
location="us-central1",
ingress="INGRESS_TRAFFIC_ALL",
template={
"containers": [{
"image": "us-docker.pkg.dev/cloudrun/container/hello",
}],
},
deletion_protection=True)
default_hosting_version = gcp.firebase.HostingVersion("default",
site_id=default.site_id,
config={
"rewrites": [{
"glob": "/hello/**",
"run": {
"service_id": default_service.name,
"region": default_service.location,
},
}],
})
default_hosting_release = gcp.firebase.HostingRelease("default",
site_id=default.site_id,
version_name=default_hosting_version.name,
message="Cloud Run Integration")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/cloudrunv2"
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/firebase"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := firebase.NewHostingSite(ctx, "default", &firebase.HostingSiteArgs{
Project: pulumi.String("my-project-name"),
SiteId: pulumi.String("site-id"),
})
if err != nil {
return err
}
defaultService, err := cloudrunv2.NewService(ctx, "default", &cloudrunv2.ServiceArgs{
Project: pulumi.String("my-project-name"),
Name: pulumi.String("cloud-run-service-via-hosting"),
Location: pulumi.String("us-central1"),
Ingress: pulumi.String("INGRESS_TRAFFIC_ALL"),
Template: &cloudrunv2.ServiceTemplateArgs{
Containers: cloudrunv2.ServiceTemplateContainerArray{
&cloudrunv2.ServiceTemplateContainerArgs{
Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
},
},
},
DeletionProtection: pulumi.Bool(true),
})
if err != nil {
return err
}
defaultHostingVersion, err := firebase.NewHostingVersion(ctx, "default", &firebase.HostingVersionArgs{
SiteId: _default.SiteId,
Config: &firebase.HostingVersionConfigArgs{
Rewrites: firebase.HostingVersionConfigRewriteArray{
&firebase.HostingVersionConfigRewriteArgs{
Glob: pulumi.String("/hello/**"),
Run: &firebase.HostingVersionConfigRewriteRunArgs{
ServiceId: defaultService.Name,
Region: defaultService.Location,
},
},
},
},
})
if err != nil {
return err
}
_, err = firebase.NewHostingRelease(ctx, "default", &firebase.HostingReleaseArgs{
SiteId: _default.SiteId,
VersionName: defaultHostingVersion.Name,
Message: pulumi.String("Cloud Run Integration"),
})
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 @default = new Gcp.Firebase.HostingSite("default", new()
{
Project = "my-project-name",
SiteId = "site-id",
});
var defaultService = new Gcp.CloudRunV2.Service("default", new()
{
Project = "my-project-name",
Name = "cloud-run-service-via-hosting",
Location = "us-central1",
Ingress = "INGRESS_TRAFFIC_ALL",
Template = new Gcp.CloudRunV2.Inputs.ServiceTemplateArgs
{
Containers = new[]
{
new Gcp.CloudRunV2.Inputs.ServiceTemplateContainerArgs
{
Image = "us-docker.pkg.dev/cloudrun/container/hello",
},
},
},
DeletionProtection = true,
});
var defaultHostingVersion = new Gcp.Firebase.HostingVersion("default", new()
{
SiteId = @default.SiteId,
Config = new Gcp.Firebase.Inputs.HostingVersionConfigArgs
{
Rewrites = new[]
{
new Gcp.Firebase.Inputs.HostingVersionConfigRewriteArgs
{
Glob = "/hello/**",
Run = new Gcp.Firebase.Inputs.HostingVersionConfigRewriteRunArgs
{
ServiceId = defaultService.Name,
Region = defaultService.Location,
},
},
},
},
});
var defaultHostingRelease = new Gcp.Firebase.HostingRelease("default", new()
{
SiteId = @default.SiteId,
VersionName = defaultHostingVersion.Name,
Message = "Cloud Run Integration",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firebase.HostingSite;
import com.pulumi.gcp.firebase.HostingSiteArgs;
import com.pulumi.gcp.cloudrunv2.Service;
import com.pulumi.gcp.cloudrunv2.ServiceArgs;
import com.pulumi.gcp.cloudrunv2.inputs.ServiceTemplateArgs;
import com.pulumi.gcp.firebase.HostingVersion;
import com.pulumi.gcp.firebase.HostingVersionArgs;
import com.pulumi.gcp.firebase.inputs.HostingVersionConfigArgs;
import com.pulumi.gcp.firebase.HostingRelease;
import com.pulumi.gcp.firebase.HostingReleaseArgs;
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 default_ = new HostingSite("default", HostingSiteArgs.builder()
.project("my-project-name")
.siteId("site-id")
.build());
var defaultService = new Service("defaultService", ServiceArgs.builder()
.project("my-project-name")
.name("cloud-run-service-via-hosting")
.location("us-central1")
.ingress("INGRESS_TRAFFIC_ALL")
.template(ServiceTemplateArgs.builder()
.containers(ServiceTemplateContainerArgs.builder()
.image("us-docker.pkg.dev/cloudrun/container/hello")
.build())
.build())
.deletionProtection(true)
.build());
var defaultHostingVersion = new HostingVersion("defaultHostingVersion", HostingVersionArgs.builder()
.siteId(default_.siteId())
.config(HostingVersionConfigArgs.builder()
.rewrites(HostingVersionConfigRewriteArgs.builder()
.glob("/hello/**")
.run(HostingVersionConfigRewriteRunArgs.builder()
.serviceId(defaultService.name())
.region(defaultService.location())
.build())
.build())
.build())
.build());
var defaultHostingRelease = new HostingRelease("defaultHostingRelease", HostingReleaseArgs.builder()
.siteId(default_.siteId())
.versionName(defaultHostingVersion.name())
.message("Cloud Run Integration")
.build());
}
}
resources:
default:
type: gcp:firebase:HostingSite
properties:
project: my-project-name
siteId: site-id
defaultService:
type: gcp:cloudrunv2:Service
name: default
properties:
project: my-project-name
name: cloud-run-service-via-hosting
location: us-central1
ingress: INGRESS_TRAFFIC_ALL
template:
containers:
- image: us-docker.pkg.dev/cloudrun/container/hello
deletionProtection: true
defaultHostingVersion:
type: gcp:firebase:HostingVersion
name: default
properties:
siteId: ${default.siteId}
config:
rewrites:
- glob: /hello/**
run:
serviceId: ${defaultService.name}
region: ${defaultService.location}
defaultHostingRelease:
type: gcp:firebase:HostingRelease
name: default
properties:
siteId: ${default.siteId}
versionName: ${defaultHostingVersion.name}
message: Cloud Run Integration
Firebasehosting Version Cloud Functions
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.firebase.HostingSite("default", {
project: "my-project-name",
siteId: "site-id",
});
const bucket = new gcp.storage.Bucket("bucket", {
project: "my-project-name",
name: "site-id-function-source",
location: "US",
uniformBucketLevelAccess: true,
});
const object = new gcp.storage.BucketObject("object", {
name: "function-source.zip",
bucket: bucket.name,
source: new pulumi.asset.FileAsset("function-source.zip"),
});
const _function = new gcp.cloudfunctions.Function("function", {
project: "my-project-name",
name: "cloud-function-via-hosting",
description: "A Cloud Function connected to Firebase Hosing",
runtime: "nodejs16",
availableMemoryMb: 128,
sourceArchiveBucket: bucket.name,
sourceArchiveObject: object.name,
triggerHttp: true,
entryPoint: "helloHttp",
});
const defaultHostingVersion = new gcp.firebase.HostingVersion("default", {
siteId: _default.siteId,
config: {
rewrites: [{
glob: "/hello/**",
"function": _function.name,
}],
},
});
const defaultHostingRelease = new gcp.firebase.HostingRelease("default", {
siteId: _default.siteId,
versionName: defaultHostingVersion.name,
message: "Cloud Functions Integration",
});
import pulumi
import pulumi_gcp as gcp
default = gcp.firebase.HostingSite("default",
project="my-project-name",
site_id="site-id")
bucket = gcp.storage.Bucket("bucket",
project="my-project-name",
name="site-id-function-source",
location="US",
uniform_bucket_level_access=True)
object = gcp.storage.BucketObject("object",
name="function-source.zip",
bucket=bucket.name,
source=pulumi.FileAsset("function-source.zip"))
function = gcp.cloudfunctions.Function("function",
project="my-project-name",
name="cloud-function-via-hosting",
description="A Cloud Function connected to Firebase Hosing",
runtime="nodejs16",
available_memory_mb=128,
source_archive_bucket=bucket.name,
source_archive_object=object.name,
trigger_http=True,
entry_point="helloHttp")
default_hosting_version = gcp.firebase.HostingVersion("default",
site_id=default.site_id,
config={
"rewrites": [{
"glob": "/hello/**",
"function": function.name,
}],
})
default_hosting_release = gcp.firebase.HostingRelease("default",
site_id=default.site_id,
version_name=default_hosting_version.name,
message="Cloud Functions Integration")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/cloudfunctions"
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/firebase"
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := firebase.NewHostingSite(ctx, "default", &firebase.HostingSiteArgs{
Project: pulumi.String("my-project-name"),
SiteId: pulumi.String("site-id"),
})
if err != nil {
return err
}
bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
Project: pulumi.String("my-project-name"),
Name: pulumi.String("site-id-function-source"),
Location: pulumi.String("US"),
UniformBucketLevelAccess: pulumi.Bool(true),
})
if err != nil {
return err
}
object, err := storage.NewBucketObject(ctx, "object", &storage.BucketObjectArgs{
Name: pulumi.String("function-source.zip"),
Bucket: bucket.Name,
Source: pulumi.NewFileAsset("function-source.zip"),
})
if err != nil {
return err
}
function, err := cloudfunctions.NewFunction(ctx, "function", &cloudfunctions.FunctionArgs{
Project: pulumi.String("my-project-name"),
Name: pulumi.String("cloud-function-via-hosting"),
Description: pulumi.String("A Cloud Function connected to Firebase Hosing"),
Runtime: pulumi.String("nodejs16"),
AvailableMemoryMb: pulumi.Int(128),
SourceArchiveBucket: bucket.Name,
SourceArchiveObject: object.Name,
TriggerHttp: pulumi.Bool(true),
EntryPoint: pulumi.String("helloHttp"),
})
if err != nil {
return err
}
defaultHostingVersion, err := firebase.NewHostingVersion(ctx, "default", &firebase.HostingVersionArgs{
SiteId: _default.SiteId,
Config: &firebase.HostingVersionConfigArgs{
Rewrites: firebase.HostingVersionConfigRewriteArray{
&firebase.HostingVersionConfigRewriteArgs{
Glob: pulumi.String("/hello/**"),
Function: function.Name,
},
},
},
})
if err != nil {
return err
}
_, err = firebase.NewHostingRelease(ctx, "default", &firebase.HostingReleaseArgs{
SiteId: _default.SiteId,
VersionName: defaultHostingVersion.Name,
Message: pulumi.String("Cloud Functions Integration"),
})
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 @default = new Gcp.Firebase.HostingSite("default", new()
{
Project = "my-project-name",
SiteId = "site-id",
});
var bucket = new Gcp.Storage.Bucket("bucket", new()
{
Project = "my-project-name",
Name = "site-id-function-source",
Location = "US",
UniformBucketLevelAccess = true,
});
var @object = new Gcp.Storage.BucketObject("object", new()
{
Name = "function-source.zip",
Bucket = bucket.Name,
Source = new FileAsset("function-source.zip"),
});
var function = new Gcp.CloudFunctions.Function("function", new()
{
Project = "my-project-name",
Name = "cloud-function-via-hosting",
Description = "A Cloud Function connected to Firebase Hosing",
Runtime = "nodejs16",
AvailableMemoryMb = 128,
SourceArchiveBucket = bucket.Name,
SourceArchiveObject = @object.Name,
TriggerHttp = true,
EntryPoint = "helloHttp",
});
var defaultHostingVersion = new Gcp.Firebase.HostingVersion("default", new()
{
SiteId = @default.SiteId,
Config = new Gcp.Firebase.Inputs.HostingVersionConfigArgs
{
Rewrites = new[]
{
new Gcp.Firebase.Inputs.HostingVersionConfigRewriteArgs
{
Glob = "/hello/**",
Function = function.Name,
},
},
},
});
var defaultHostingRelease = new Gcp.Firebase.HostingRelease("default", new()
{
SiteId = @default.SiteId,
VersionName = defaultHostingVersion.Name,
Message = "Cloud Functions Integration",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firebase.HostingSite;
import com.pulumi.gcp.firebase.HostingSiteArgs;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.gcp.cloudfunctions.Function;
import com.pulumi.gcp.cloudfunctions.FunctionArgs;
import com.pulumi.gcp.firebase.HostingVersion;
import com.pulumi.gcp.firebase.HostingVersionArgs;
import com.pulumi.gcp.firebase.inputs.HostingVersionConfigArgs;
import com.pulumi.gcp.firebase.HostingRelease;
import com.pulumi.gcp.firebase.HostingReleaseArgs;
import com.pulumi.asset.FileAsset;
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 default_ = new HostingSite("default", HostingSiteArgs.builder()
.project("my-project-name")
.siteId("site-id")
.build());
var bucket = new Bucket("bucket", BucketArgs.builder()
.project("my-project-name")
.name("site-id-function-source")
.location("US")
.uniformBucketLevelAccess(true)
.build());
var object = new BucketObject("object", BucketObjectArgs.builder()
.name("function-source.zip")
.bucket(bucket.name())
.source(new FileAsset("function-source.zip"))
.build());
var function = new Function("function", FunctionArgs.builder()
.project("my-project-name")
.name("cloud-function-via-hosting")
.description("A Cloud Function connected to Firebase Hosing")
.runtime("nodejs16")
.availableMemoryMb(128)
.sourceArchiveBucket(bucket.name())
.sourceArchiveObject(object.name())
.triggerHttp(true)
.entryPoint("helloHttp")
.build());
var defaultHostingVersion = new HostingVersion("defaultHostingVersion", HostingVersionArgs.builder()
.siteId(default_.siteId())
.config(HostingVersionConfigArgs.builder()
.rewrites(HostingVersionConfigRewriteArgs.builder()
.glob("/hello/**")
.function(function.name())
.build())
.build())
.build());
var defaultHostingRelease = new HostingRelease("defaultHostingRelease", HostingReleaseArgs.builder()
.siteId(default_.siteId())
.versionName(defaultHostingVersion.name())
.message("Cloud Functions Integration")
.build());
}
}
resources:
default:
type: gcp:firebase:HostingSite
properties:
project: my-project-name
siteId: site-id
bucket:
type: gcp:storage:Bucket
properties:
project: my-project-name
name: site-id-function-source
location: US
uniformBucketLevelAccess: true
object:
type: gcp:storage:BucketObject
properties:
name: function-source.zip
bucket: ${bucket.name}
source:
fn::FileAsset: function-source.zip
function:
type: gcp:cloudfunctions:Function
properties:
project: my-project-name
name: cloud-function-via-hosting
description: A Cloud Function connected to Firebase Hosing
runtime: nodejs16
availableMemoryMb: 128
sourceArchiveBucket: ${bucket.name}
sourceArchiveObject: ${object.name}
triggerHttp: true
entryPoint: helloHttp
defaultHostingVersion:
type: gcp:firebase:HostingVersion
name: default
properties:
siteId: ${default.siteId}
config:
rewrites:
- glob: /hello/**
function: ${function.name}
defaultHostingRelease:
type: gcp:firebase:HostingRelease
name: default
properties:
siteId: ${default.siteId}
versionName: ${defaultHostingVersion.name}
message: Cloud Functions Integration
Create HostingVersion Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new HostingVersion(name: string, args: HostingVersionArgs, opts?: CustomResourceOptions);
@overload
def HostingVersion(resource_name: str,
args: HostingVersionArgs,
opts: Optional[ResourceOptions] = None)
@overload
def HostingVersion(resource_name: str,
opts: Optional[ResourceOptions] = None,
site_id: Optional[str] = None,
config: Optional[HostingVersionConfigArgs] = None)
func NewHostingVersion(ctx *Context, name string, args HostingVersionArgs, opts ...ResourceOption) (*HostingVersion, error)
public HostingVersion(string name, HostingVersionArgs args, CustomResourceOptions? opts = null)
public HostingVersion(String name, HostingVersionArgs args)
public HostingVersion(String name, HostingVersionArgs args, CustomResourceOptions options)
type: gcp:firebase:HostingVersion
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args HostingVersionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args HostingVersionArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args HostingVersionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args HostingVersionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args HostingVersionArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var hostingVersionResource = new Gcp.Firebase.HostingVersion("hostingVersionResource", new()
{
SiteId = "string",
Config = new Gcp.Firebase.Inputs.HostingVersionConfigArgs
{
Redirects = new[]
{
new Gcp.Firebase.Inputs.HostingVersionConfigRedirectArgs
{
Location = "string",
StatusCode = 0,
Glob = "string",
Regex = "string",
},
},
Rewrites = new[]
{
new Gcp.Firebase.Inputs.HostingVersionConfigRewriteArgs
{
Function = "string",
Glob = "string",
Path = "string",
Regex = "string",
Run = new Gcp.Firebase.Inputs.HostingVersionConfigRewriteRunArgs
{
ServiceId = "string",
Region = "string",
},
},
},
},
});
example, err := firebase.NewHostingVersion(ctx, "hostingVersionResource", &firebase.HostingVersionArgs{
SiteId: pulumi.String("string"),
Config: &firebase.HostingVersionConfigArgs{
Redirects: firebase.HostingVersionConfigRedirectArray{
&firebase.HostingVersionConfigRedirectArgs{
Location: pulumi.String("string"),
StatusCode: pulumi.Int(0),
Glob: pulumi.String("string"),
Regex: pulumi.String("string"),
},
},
Rewrites: firebase.HostingVersionConfigRewriteArray{
&firebase.HostingVersionConfigRewriteArgs{
Function: pulumi.String("string"),
Glob: pulumi.String("string"),
Path: pulumi.String("string"),
Regex: pulumi.String("string"),
Run: &firebase.HostingVersionConfigRewriteRunArgs{
ServiceId: pulumi.String("string"),
Region: pulumi.String("string"),
},
},
},
},
})
var hostingVersionResource = new HostingVersion("hostingVersionResource", HostingVersionArgs.builder()
.siteId("string")
.config(HostingVersionConfigArgs.builder()
.redirects(HostingVersionConfigRedirectArgs.builder()
.location("string")
.statusCode(0)
.glob("string")
.regex("string")
.build())
.rewrites(HostingVersionConfigRewriteArgs.builder()
.function("string")
.glob("string")
.path("string")
.regex("string")
.run(HostingVersionConfigRewriteRunArgs.builder()
.serviceId("string")
.region("string")
.build())
.build())
.build())
.build());
hosting_version_resource = gcp.firebase.HostingVersion("hostingVersionResource",
site_id="string",
config={
"redirects": [{
"location": "string",
"status_code": 0,
"glob": "string",
"regex": "string",
}],
"rewrites": [{
"function": "string",
"glob": "string",
"path": "string",
"regex": "string",
"run": {
"service_id": "string",
"region": "string",
},
}],
})
const hostingVersionResource = new gcp.firebase.HostingVersion("hostingVersionResource", {
siteId: "string",
config: {
redirects: [{
location: "string",
statusCode: 0,
glob: "string",
regex: "string",
}],
rewrites: [{
"function": "string",
glob: "string",
path: "string",
regex: "string",
run: {
serviceId: "string",
region: "string",
},
}],
},
});
type: gcp:firebase:HostingVersion
properties:
config:
redirects:
- glob: string
location: string
regex: string
statusCode: 0
rewrites:
- function: string
glob: string
path: string
regex: string
run:
region: string
serviceId: string
siteId: string
HostingVersion Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The HostingVersion resource accepts the following input properties:
- Site
Id string - Required. The ID of the site in which to create this Version.
- Config
Hosting
Version Config - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below.
- Site
Id string - Required. The ID of the site in which to create this Version.
- Config
Hosting
Version Config Args - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below.
- site
Id String - Required. The ID of the site in which to create this Version.
- config
Hosting
Version Config - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below.
- site
Id string - Required. The ID of the site in which to create this Version.
- config
Hosting
Version Config - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below.
- site_
id str - Required. The ID of the site in which to create this Version.
- config
Hosting
Version Config Args - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below.
- site
Id String - Required. The ID of the site in which to create this Version.
- config Property Map
- The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below.
Outputs
All input properties are implicitly available as output properties. Additionally, the HostingVersion resource produces the following output properties:
- id str
- The provider-assigned unique ID for this managed resource.
- name str
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID
- version_
id str - The ID for the version as in sites/SITE_ID/versions/VERSION_ID
Look up Existing HostingVersion Resource
Get an existing HostingVersion resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: HostingVersionState, opts?: CustomResourceOptions): HostingVersion
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
config: Optional[HostingVersionConfigArgs] = None,
name: Optional[str] = None,
site_id: Optional[str] = None,
version_id: Optional[str] = None) -> HostingVersion
func GetHostingVersion(ctx *Context, name string, id IDInput, state *HostingVersionState, opts ...ResourceOption) (*HostingVersion, error)
public static HostingVersion Get(string name, Input<string> id, HostingVersionState? state, CustomResourceOptions? opts = null)
public static HostingVersion get(String name, Output<String> id, HostingVersionState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Config
Hosting
Version Config - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below. - Name string
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID
- Site
Id string - Required. The ID of the site in which to create this Version.
- Version
Id string - The ID for the version as in sites/SITE_ID/versions/VERSION_ID
- Config
Hosting
Version Config Args - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below. - Name string
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID
- Site
Id string - Required. The ID of the site in which to create this Version.
- Version
Id string - The ID for the version as in sites/SITE_ID/versions/VERSION_ID
- config
Hosting
Version Config - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below. - name String
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID
- site
Id String - Required. The ID of the site in which to create this Version.
- version
Id String - The ID for the version as in sites/SITE_ID/versions/VERSION_ID
- config
Hosting
Version Config - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below. - name string
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID
- site
Id string - Required. The ID of the site in which to create this Version.
- version
Id string - The ID for the version as in sites/SITE_ID/versions/VERSION_ID
- config
Hosting
Version Config Args - The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below. - name str
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID
- site_
id str - Required. The ID of the site in which to create this Version.
- version_
id str - The ID for the version as in sites/SITE_ID/versions/VERSION_ID
- config Property Map
- The configuration for the behavior of the site. This configuration exists in the
firebase.json
file. Structure is documented below. - name String
- The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID
- site
Id String - Required. The ID of the site in which to create this Version.
- version
Id String - The ID for the version as in sites/SITE_ID/versions/VERSION_ID
Supporting Types
HostingVersionConfig, HostingVersionConfigArgs
- Redirects
List<Hosting
Version Config Redirect> - An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path. Structure is documented below.
- Rewrites
List<Hosting
Version Config Rewrite> - An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL. Structure is documented below.
- Redirects
[]Hosting
Version Config Redirect - An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path. Structure is documented below.
- Rewrites
[]Hosting
Version Config Rewrite - An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL. Structure is documented below.
- redirects
List<Hosting
Version Config Redirect> - An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path. Structure is documented below.
- rewrites
List<Hosting
Version Config Rewrite> - An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL. Structure is documented below.
- redirects
Hosting
Version Config Redirect[] - An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path. Structure is documented below.
- rewrites
Hosting
Version Config Rewrite[] - An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL. Structure is documented below.
- redirects
Sequence[Hosting
Version Config Redirect] - An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path. Structure is documented below.
- rewrites
Sequence[Hosting
Version Config Rewrite] - An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL. Structure is documented below.
- redirects List<Property Map>
- An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path. Structure is documented below.
- rewrites List<Property Map>
- An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL. Structure is documented below.
HostingVersionConfigRedirect, HostingVersionConfigRedirectArgs
- Location string
- The value to put in the HTTP location header of the response. The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:
- Status
Code int - The status HTTP code to return in the response. It must be a valid 3xx status code.
- Glob string
- The user-supplied glob to match against the request URL path.
- Regex string
- The user-supplied RE2 regular expression to match against the request URL path.
- Location string
- The value to put in the HTTP location header of the response. The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:
- Status
Code int - The status HTTP code to return in the response. It must be a valid 3xx status code.
- Glob string
- The user-supplied glob to match against the request URL path.
- Regex string
- The user-supplied RE2 regular expression to match against the request URL path.
- location String
- The value to put in the HTTP location header of the response. The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:
- status
Code Integer - The status HTTP code to return in the response. It must be a valid 3xx status code.
- glob String
- The user-supplied glob to match against the request URL path.
- regex String
- The user-supplied RE2 regular expression to match against the request URL path.
- location string
- The value to put in the HTTP location header of the response. The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:
- status
Code number - The status HTTP code to return in the response. It must be a valid 3xx status code.
- glob string
- The user-supplied glob to match against the request URL path.
- regex string
- The user-supplied RE2 regular expression to match against the request URL path.
- location str
- The value to put in the HTTP location header of the response. The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:
- status_
code int - The status HTTP code to return in the response. It must be a valid 3xx status code.
- glob str
- The user-supplied glob to match against the request URL path.
- regex str
- The user-supplied RE2 regular expression to match against the request URL path.
- location String
- The value to put in the HTTP location header of the response. The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:
- status
Code Number - The status HTTP code to return in the response. It must be a valid 3xx status code.
- glob String
- The user-supplied glob to match against the request URL path.
- regex String
- The user-supplied RE2 regular expression to match against the request URL path.
HostingVersionConfigRewrite, HostingVersionConfigRewriteArgs
- Function string
- The function to proxy requests to. Must match the exported function name exactly.
- Glob string
- The user-supplied glob to match against the request URL path.
- Path string
- The URL path to rewrite the request to.
- Regex string
- The user-supplied RE2 regular expression to match against the request URL path.
- Run
Hosting
Version Config Rewrite Run - The request will be forwarded to Cloud Run. Structure is documented below.
- Function string
- The function to proxy requests to. Must match the exported function name exactly.
- Glob string
- The user-supplied glob to match against the request URL path.
- Path string
- The URL path to rewrite the request to.
- Regex string
- The user-supplied RE2 regular expression to match against the request URL path.
- Run
Hosting
Version Config Rewrite Run - The request will be forwarded to Cloud Run. Structure is documented below.
- function String
- The function to proxy requests to. Must match the exported function name exactly.
- glob String
- The user-supplied glob to match against the request URL path.
- path String
- The URL path to rewrite the request to.
- regex String
- The user-supplied RE2 regular expression to match against the request URL path.
- run
Hosting
Version Config Rewrite Run - The request will be forwarded to Cloud Run. Structure is documented below.
- function string
- The function to proxy requests to. Must match the exported function name exactly.
- glob string
- The user-supplied glob to match against the request URL path.
- path string
- The URL path to rewrite the request to.
- regex string
- The user-supplied RE2 regular expression to match against the request URL path.
- run
Hosting
Version Config Rewrite Run - The request will be forwarded to Cloud Run. Structure is documented below.
- function str
- The function to proxy requests to. Must match the exported function name exactly.
- glob str
- The user-supplied glob to match against the request URL path.
- path str
- The URL path to rewrite the request to.
- regex str
- The user-supplied RE2 regular expression to match against the request URL path.
- run
Hosting
Version Config Rewrite Run - The request will be forwarded to Cloud Run. Structure is documented below.
- function String
- The function to proxy requests to. Must match the exported function name exactly.
- glob String
- The user-supplied glob to match against the request URL path.
- path String
- The URL path to rewrite the request to.
- regex String
- The user-supplied RE2 regular expression to match against the request URL path.
- run Property Map
- The request will be forwarded to Cloud Run. Structure is documented below.
HostingVersionConfigRewriteRun, HostingVersionConfigRewriteRunArgs
- service_
id str - User-defined ID of the Cloud Run service.
- region str
- Optional. User-provided region where the Cloud Run service is hosted. Defaults to
us-central1
if not supplied.
Import
Version can be imported using any of these accepted formats:
sites/{{site_id}}/versions/{{version_id}}
{{site_id}}/{{version_id}}
When using the pulumi import
command, Version can be imported using one of the formats above. For example:
$ pulumi import gcp:firebase/hostingVersion:HostingVersion default sites/{{site_id}}/versions/{{version_id}}
$ pulumi import gcp:firebase/hostingVersion:HostingVersion default {{site_id}}/{{version_id}}
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
google-beta
Terraform Provider.