UNPKG

@pulumi/gcp

Version:

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

512 lines • 21.6 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! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.EdgeCacheService = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * EdgeCacheService defines the IP addresses, protocols, security policies, cache policies and routing configuration. * * > **Warning:** These resources require allow-listing to use, and are not openly available to all Cloud customers. Engage with your Cloud account team to discuss how to onboard. * * ## Example Usage * * ### Network Services Edge Cache Service Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const dest = new gcp.storage.Bucket("dest", { * name: "my-bucket", * location: "US", * forceDestroy: true, * }); * const instance = new gcp.networkservices.EdgeCacheOrigin("instance", { * name: "my-origin", * originAddress: dest.url, * description: "The default bucket for media edge test", * maxAttempts: 2, * timeout: { * connectTimeout: "10s", * }, * }); * const instanceEdgeCacheService = new gcp.networkservices.EdgeCacheService("instance", { * name: "my-service", * description: "some description", * routing: { * hostRules: [{ * description: "host rule description", * hosts: ["sslcert.tf-test.club"], * pathMatcher: "routes", * }], * pathMatchers: [{ * name: "routes", * routeRules: [{ * description: "a route rule to match against", * priority: "1", * matchRules: [{ * prefixMatch: "/", * }], * origin: instance.name, * routeAction: { * cdnPolicy: { * cacheMode: "CACHE_ALL_STATIC", * defaultTtl: "3600s", * }, * }, * headerAction: { * responseHeaderToAdds: [{ * headerName: "x-cache-status", * headerValue: "{cdn_cache_status}", * }], * }, * }], * }], * }, * }); * ``` * ### Network Services Edge Cache Service Advanced * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const dest = new gcp.storage.Bucket("dest", { * name: "my-bucket", * location: "US", * forceDestroy: true, * }); * const google = new gcp.networkservices.EdgeCacheOrigin("google", { * name: "origin-google", * originAddress: "google.com", * description: "The default bucket for media edge test", * maxAttempts: 2, * timeout: { * connectTimeout: "10s", * }, * }); * const instance = new gcp.networkservices.EdgeCacheOrigin("instance", { * name: "my-origin", * originAddress: dest.url, * description: "The default bucket for media edge test", * maxAttempts: 2, * timeout: { * connectTimeout: "10s", * }, * }); * const instanceEdgeCacheService = new gcp.networkservices.EdgeCacheService("instance", { * name: "my-service", * description: "some description", * disableQuic: true, * disableHttp2: true, * labels: { * a: "b", * }, * routing: { * hostRules: [ * { * description: "host rule description", * hosts: ["sslcert.tf-test.club"], * pathMatcher: "routes", * }, * { * description: "host rule2", * hosts: ["sslcert.tf-test2.club"], * pathMatcher: "routes", * }, * { * description: "host rule3", * hosts: ["sslcert.tf-test3.club"], * pathMatcher: "routesAdvanced", * }, * ], * pathMatchers: [ * { * name: "routes", * routeRules: [{ * description: "a route rule to match against", * priority: "1", * matchRules: [{ * prefixMatch: "/", * }], * origin: instance.name, * routeAction: { * cdnPolicy: { * cacheMode: "CACHE_ALL_STATIC", * defaultTtl: "3600s", * }, * }, * headerAction: { * responseHeaderToAdds: [{ * headerName: "x-cache-status", * headerValue: "{cdn_cache_status}", * }], * }, * }], * }, * { * name: "routesAdvanced", * description: "an advanced ruleset", * routeRules: [ * { * description: "an advanced route rule to match against", * priority: "1", * matchRules: [ * { * prefixMatch: "/potato/", * queryParameterMatches: [ * { * name: "debug", * presentMatch: true, * }, * { * name: "state", * exactMatch: "debug", * }, * ], * }, * { * fullPathMatch: "/apple", * }, * ], * headerAction: { * requestHeaderToAdds: [ * { * headerName: "debug", * headerValue: "true", * replace: true, * }, * { * headerName: "potato", * headerValue: "plant", * }, * ], * responseHeaderToAdds: [{ * headerName: "potato", * headerValue: "plant", * replace: true, * }], * requestHeaderToRemoves: [{ * headerName: "prod", * }], * responseHeaderToRemoves: [{ * headerName: "prod", * }], * }, * origin: instance.name, * routeAction: { * cdnPolicy: { * cacheMode: "CACHE_ALL_STATIC", * defaultTtl: "3800s", * clientTtl: "3600s", * maxTtl: "9000s", * cacheKeyPolicy: { * includeProtocol: true, * excludeHost: true, * includedQueryParameters: [ * "apple", * "dev", * "santa", * "claus", * ], * includedHeaderNames: ["banana"], * includedCookieNames: ["orange"], * }, * negativeCaching: true, * signedRequestMode: "DISABLED", * negativeCachingPolicy: { * "500": "3000s", * }, * }, * urlRewrite: { * pathPrefixRewrite: "/dev", * hostRewrite: "dev.club", * }, * corsPolicy: { * maxAge: "2500s", * allowCredentials: true, * allowOrigins: ["*"], * allowMethods: ["GET"], * allowHeaders: ["dev"], * exposeHeaders: ["prod"], * }, * }, * }, * { * description: "a second route rule to match against", * priority: "2", * matchRules: [{ * fullPathMatch: "/yay", * }], * origin: instance.name, * routeAction: { * cdnPolicy: { * cacheMode: "CACHE_ALL_STATIC", * defaultTtl: "3600s", * cacheKeyPolicy: { * excludedQueryParameters: ["dev"], * }, * }, * corsPolicy: { * maxAge: "3000s", * allowHeaders: ["dev"], * disabled: true, * }, * }, * }, * ], * }, * ], * }, * logConfig: { * enable: true, * sampleRate: 0.01, * }, * }); * ``` * ### Network Services Edge Cache Service Dual Token * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const secret_basic = new gcp.secretmanager.Secret("secret-basic", { * secretId: "secret-name", * replication: { * auto: {}, * }, * }); * const secret_version_basic = new gcp.secretmanager.SecretVersion("secret-version-basic", { * secret: secret_basic.id, * secretData: "secret-data", * }); * const keyset = new gcp.networkservices.EdgeCacheKeyset("keyset", { * name: "keyset-name", * description: "The default keyset", * publicKeys: [{ * id: "my-public-key", * managed: true, * }], * validationSharedKeys: [{ * secretVersion: secret_version_basic.id, * }], * }); * const instance = new gcp.networkservices.EdgeCacheOrigin("instance", { * name: "my-origin", * originAddress: "gs://media-edge-default", * description: "The default bucket for media edge test", * }); * const instanceEdgeCacheService = new gcp.networkservices.EdgeCacheService("instance", { * name: "my-service", * description: "some description", * routing: { * hostRules: [{ * description: "host rule description", * hosts: ["sslcert.tf-test.club"], * pathMatcher: "routes", * }], * pathMatchers: [{ * name: "routes", * routeRules: [ * { * description: "a route rule to match against master playlist", * priority: "1", * matchRules: [{ * pathTemplateMatch: "/master.m3u8", * }], * origin: instance.name, * routeAction: { * cdnPolicy: { * signedRequestMode: "REQUIRE_TOKENS", * signedRequestKeyset: keyset.id, * signedTokenOptions: { * tokenQueryParameter: "edge-cache-token", * }, * signedRequestMaximumExpirationTtl: "600s", * addSignatures: { * actions: "GENERATE_COOKIE", * keyset: keyset.id, * copiedParameters: [ * "PathGlobs", * "SessionID", * ], * }, * }, * }, * }, * { * description: "a route rule to match against all playlists", * priority: "2", * matchRules: [{ * pathTemplateMatch: "/*.m3u8", * }], * origin: instance.name, * routeAction: { * cdnPolicy: { * signedRequestMode: "REQUIRE_TOKENS", * signedRequestKeyset: keyset.id, * signedTokenOptions: { * tokenQueryParameter: "hdnts", * allowedSignatureAlgorithms: [ * "ED25519", * "HMAC_SHA_256", * "HMAC_SHA1", * ], * }, * addSignatures: { * actions: "GENERATE_TOKEN_HLS_COOKIELESS", * keyset: keyset.id, * tokenTtl: "1200s", * tokenQueryParameter: "hdntl", * copiedParameters: ["URLPrefix"], * }, * }, * }, * }, * { * description: "a route rule to match against", * priority: "3", * matchRules: [{ * pathTemplateMatch: "/**.m3u8", * }], * origin: instance.name, * routeAction: { * cdnPolicy: { * signedRequestMode: "REQUIRE_TOKENS", * signedRequestKeyset: keyset.id, * signedTokenOptions: { * tokenQueryParameter: "hdntl", * }, * addSignatures: { * actions: "PROPAGATE_TOKEN_HLS_COOKIELESS", * tokenQueryParameter: "hdntl", * }, * }, * }, * }, * ], * }], * }, * }); * ``` * * ## Import * * EdgeCacheService can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/global/edgeCacheServices/{{name}}` * * `{{project}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, EdgeCacheService can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:networkservices/edgeCacheService:EdgeCacheService default projects/{{project}}/locations/global/edgeCacheServices/{{name}} * $ pulumi import gcp:networkservices/edgeCacheService:EdgeCacheService default {{project}}/{{name}} * $ pulumi import gcp:networkservices/edgeCacheService:EdgeCacheService default {{name}} * ``` */ class EdgeCacheService extends pulumi.CustomResource { /** * Get an existing EdgeCacheService 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 EdgeCacheService(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:networkservices/edgeCacheService:EdgeCacheService'; /** * Returns true if the given object is an instance of EdgeCacheService. 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'] === EdgeCacheService.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["description"] = state?.description; resourceInputs["disableHttp2"] = state?.disableHttp2; resourceInputs["disableQuic"] = state?.disableQuic; resourceInputs["edgeSecurityPolicy"] = state?.edgeSecurityPolicy; resourceInputs["edgeSslCertificates"] = state?.edgeSslCertificates; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["ipv4Addresses"] = state?.ipv4Addresses; resourceInputs["ipv6Addresses"] = state?.ipv6Addresses; resourceInputs["labels"] = state?.labels; resourceInputs["logConfig"] = state?.logConfig; resourceInputs["name"] = state?.name; resourceInputs["project"] = state?.project; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["requireTls"] = state?.requireTls; resourceInputs["routing"] = state?.routing; resourceInputs["sslPolicy"] = state?.sslPolicy; } else { const args = argsOrState; if (args?.routing === undefined && !opts.urn) { throw new Error("Missing required property 'routing'"); } resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["description"] = args?.description; resourceInputs["disableHttp2"] = args?.disableHttp2; resourceInputs["disableQuic"] = args?.disableQuic; resourceInputs["edgeSecurityPolicy"] = args?.edgeSecurityPolicy; resourceInputs["edgeSslCertificates"] = args?.edgeSslCertificates; resourceInputs["labels"] = args?.labels; resourceInputs["logConfig"] = args?.logConfig; resourceInputs["name"] = args?.name; resourceInputs["project"] = args?.project; resourceInputs["requireTls"] = args?.requireTls; resourceInputs["routing"] = args?.routing; resourceInputs["sslPolicy"] = args?.sslPolicy; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["ipv4Addresses"] = undefined /*out*/; resourceInputs["ipv6Addresses"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(EdgeCacheService.__pulumiType, name, resourceInputs, opts); } } exports.EdgeCacheService = EdgeCacheService; //# sourceMappingURL=edgeCacheService.js.map