UNPKG

@pulumi/gcp

Version:

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

272 lines • 9.18 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** 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"); /** * ## 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.cloudfunctions.Function("function", { * project: "my-project-name", * name: "cloud-function-via-hosting", * description: "A Cloud Function connected to Firebase Hosing", * runtime: "nodejs20", * 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 * * 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, Object.assign(Object.assign({}, 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 ? state.config : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["siteId"] = state ? state.siteId : undefined; resourceInputs["versionId"] = state ? state.versionId : undefined; } else { const args = argsOrState; if ((!args || args.siteId === undefined) && !opts.urn) { throw new Error("Missing required property 'siteId'"); } resourceInputs["config"] = args ? args.config : undefined; resourceInputs["siteId"] = args ? args.siteId : undefined; 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