UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

290 lines • 9.62 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.HostingVersion = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * A `Version` is a configuration which determine how a site is displayed. Static files are not supported at the moment. * * To get more information about Version, see: * * * [API documentation](https://firebase.google.com/docs/reference/hosting/rest/v1beta1/sites.versions) * * How-to Guides * * [Official Documentation](https://firebase.google.com/docs/hosting) * * ## Example Usage * * ### Firebasehosting Version Redirect * * ```typescript * 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", * }); * ``` * ### Firebasehosting Version Headers * * ```typescript * 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: { * headers: [{ * glob: "/headers/**", * headers: { * "my-header": "my-value", * }, * }], * }, * }); * const defaultHostingRelease = new gcp.firebase.HostingRelease("default", { * siteId: _default.siteId, * versionName: defaultHostingVersion.name, * message: "With custom headers", * }); * ``` * ### Firebasehosting Version Headers Regex * * ```typescript * 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: { * headers: [{ * regex: "^~/headers$", * headers: { * "my-header": "my-value", * }, * }], * }, * }); * const defaultHostingRelease = new gcp.firebase.HostingRelease("default", { * siteId: _default.siteId, * versionName: defaultHostingVersion.name, * message: "With custom headers", * }); * ``` * ### Firebasehosting Version Path * * ```typescript * 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", * }); * ``` * ### Firebasehosting Version Cloud Run * * ```typescript * 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", * }); * ``` * ### Firebasehosting Version Cloud Functions * * ```typescript * 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.cloudfunctionsv2.Function("function", { * project: "my-project-name", * name: "cloud-function-via-hosting", * location: "us-central1", * description: "A Cloud Function connected to Firebase Hosing", * buildConfig: { * runtime: "nodejs22", * entryPoint: "helloHttp", * source: { * storageSource: { * bucket: bucket.name, * object: object.name, * }, * }, * }, * serviceConfig: { * maxInstanceCount: 1, * availableMemory: "256M", * timeoutSeconds: 60, * }, * }); * 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 * * 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: * * ```sh * $ pulumi import gcp:firebase/hostingVersion:HostingVersion default sites/{{site_id}}/versions/{{version_id}} * ``` * * ```sh * $ pulumi import gcp:firebase/hostingVersion:HostingVersion default {{site_id}}/{{version_id}} * ``` */ class HostingVersion extends pulumi.CustomResource { /** * Get an existing HostingVersion resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new HostingVersion(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of HostingVersion. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === HostingVersion.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["config"] = state?.config; resourceInputs["name"] = state?.name; resourceInputs["siteId"] = state?.siteId; resourceInputs["versionId"] = state?.versionId; } else { const args = argsOrState; if (args?.siteId === undefined && !opts.urn) { throw new Error("Missing required property 'siteId'"); } resourceInputs["config"] = args?.config; resourceInputs["siteId"] = args?.siteId; resourceInputs["name"] = undefined /*out*/; resourceInputs["versionId"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(HostingVersion.__pulumiType, name, resourceInputs, opts); } } exports.HostingVersion = HostingVersion; /** @internal */ HostingVersion.__pulumiType = 'gcp:firebase/hostingVersion:HostingVersion'; //# sourceMappingURL=hostingVersion.js.map