UNPKG

@pulumi/gcp

Version:

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

495 lines • 21 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.EdgeCacheService = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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}} * ``` * * ```sh * $ pulumi import gcp:networkservices/edgeCacheService:EdgeCacheService default {{project}}/{{name}} * ``` * * ```sh * $ 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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["description"] = state ? state.description : undefined; resourceInputs["disableHttp2"] = state ? state.disableHttp2 : undefined; resourceInputs["disableQuic"] = state ? state.disableQuic : undefined; resourceInputs["edgeSecurityPolicy"] = state ? state.edgeSecurityPolicy : undefined; resourceInputs["edgeSslCertificates"] = state ? state.edgeSslCertificates : undefined; resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined; resourceInputs["ipv4Addresses"] = state ? state.ipv4Addresses : undefined; resourceInputs["ipv6Addresses"] = state ? state.ipv6Addresses : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["logConfig"] = state ? state.logConfig : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined; resourceInputs["requireTls"] = state ? state.requireTls : undefined; resourceInputs["routing"] = state ? state.routing : undefined; resourceInputs["sslPolicy"] = state ? state.sslPolicy : undefined; } else { const args = argsOrState; if ((!args || args.routing === undefined) && !opts.urn) { throw new Error("Missing required property 'routing'"); } resourceInputs["description"] = args ? args.description : undefined; resourceInputs["disableHttp2"] = args ? args.disableHttp2 : undefined; resourceInputs["disableQuic"] = args ? args.disableQuic : undefined; resourceInputs["edgeSecurityPolicy"] = args ? args.edgeSecurityPolicy : undefined; resourceInputs["edgeSslCertificates"] = args ? args.edgeSslCertificates : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["logConfig"] = args ? args.logConfig : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["requireTls"] = args ? args.requireTls : undefined; resourceInputs["routing"] = args ? args.routing : undefined; resourceInputs["sslPolicy"] = args ? args.sslPolicy : undefined; 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; /** @internal */ EdgeCacheService.__pulumiType = 'gcp:networkservices/edgeCacheService:EdgeCacheService'; //# sourceMappingURL=edgeCacheService.js.map