@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
1,358 lines • 43.5 kB
JavaScript
"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.URLMap = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* UrlMaps are used to route requests to a backend service based on rules
* that you define for the host and path of an incoming URL.
*
* To get more information about UrlMap, see:
*
* * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/load-balancing/docs/url-map-concepts)
*
* ## Example Usage
*
* ### Url Map Bucket And Service
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HttpHealthCheck("default", {
* name: "health-check",
* requestPath: "/",
* checkIntervalSec: 1,
* timeoutSec: 1,
* });
* const login = new gcp.compute.BackendService("login", {
* name: "login",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: _default.id,
* });
* const staticBucket = new gcp.storage.Bucket("static", {
* name: "static-asset-bucket",
* location: "US",
* });
* const static = new gcp.compute.BackendBucket("static", {
* name: "static-asset-backend-bucket",
* bucketName: staticBucket.name,
* enableCdn: true,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "a description",
* defaultService: static.id,
* hostRules: [
* {
* hosts: ["mysite.com"],
* pathMatcher: "mysite",
* },
* {
* hosts: ["myothersite.com"],
* pathMatcher: "otherpaths",
* },
* ],
* pathMatchers: [
* {
* name: "mysite",
* defaultService: static.id,
* pathRules: [
* {
* paths: ["/home"],
* service: static.id,
* },
* {
* paths: ["/login"],
* service: login.id,
* },
* {
* paths: ["/static"],
* service: static.id,
* },
* ],
* },
* {
* name: "otherpaths",
* defaultService: static.id,
* },
* ],
* tests: [{
* service: static.id,
* host: "example.com",
* path: "/home",
* }],
* });
* ```
* ### Url Map Traffic Director Route
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: _default.id,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "a description",
* defaultService: home.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* routeRules: [{
* priority: 1,
* headerAction: {
* requestHeadersToRemoves: ["RemoveMe2"],
* requestHeadersToAdds: [{
* headerName: "AddSomethingElse",
* headerValue: "MyOtherValue",
* replace: true,
* }],
* responseHeadersToRemoves: ["RemoveMe3"],
* responseHeadersToAdds: [{
* headerName: "AddMe",
* headerValue: "MyValue",
* replace: false,
* }],
* },
* matchRules: [{
* fullPathMatch: "a full path",
* headerMatches: [{
* headerName: "someheader",
* exactMatch: "match this exactly",
* invertMatch: true,
* }],
* ignoreCase: true,
* metadataFilters: [{
* filterMatchCriteria: "MATCH_ANY",
* filterLabels: [{
* name: "PLANET",
* value: "MARS",
* }],
* }],
* queryParameterMatches: [{
* name: "a query parameter",
* presentMatch: true,
* }],
* }],
* urlRedirect: {
* hostRedirect: "A host",
* httpsRedirect: false,
* pathRedirect: "some/path",
* redirectResponseCode: "TEMPORARY_REDIRECT",
* stripQuery: true,
* },
* }],
* }],
* tests: [{
* service: home.id,
* host: "hi.com",
* path: "/home",
* }],
* });
* ```
* ### Url Map Traffic Director Route Partial
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: _default.id,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "a description",
* defaultService: home.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* routeRules: [{
* priority: 1,
* matchRules: [{
* prefixMatch: "/someprefix",
* headerMatches: [{
* headerName: "someheader",
* exactMatch: "match this exactly",
* invertMatch: true,
* }],
* }],
* urlRedirect: {
* pathRedirect: "some/path",
* redirectResponseCode: "TEMPORARY_REDIRECT",
* },
* }],
* }],
* tests: [{
* service: home.id,
* host: "hi.com",
* path: "/home",
* }],
* });
* ```
* ### Url Map Traffic Director Path
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: _default.id,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "a description",
* defaultService: home.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* pathRules: [{
* paths: ["/home"],
* routeAction: {
* corsPolicy: {
* allowCredentials: true,
* allowHeaders: ["Allowed content"],
* allowMethods: ["GET"],
* allowOriginRegexes: ["abc.*"],
* allowOrigins: ["Allowed origin"],
* exposeHeaders: ["Exposed header"],
* maxAge: 30,
* disabled: false,
* },
* faultInjectionPolicy: {
* abort: {
* httpStatus: 234,
* percentage: 5.6,
* },
* delay: {
* fixedDelay: {
* seconds: "0",
* nanos: 50000,
* },
* percentage: 7.8,
* },
* },
* requestMirrorPolicy: {
* backendService: home.id,
* },
* retryPolicy: {
* numRetries: 4,
* perTryTimeout: {
* seconds: "30",
* },
* retryConditions: [
* "5xx",
* "deadline-exceeded",
* ],
* },
* timeout: {
* seconds: "20",
* nanos: 750000000,
* },
* urlRewrite: {
* hostRewrite: "dev.example.com",
* pathPrefixRewrite: "/v1/api/",
* },
* weightedBackendServices: [{
* backendService: home.id,
* weight: 400,
* headerAction: {
* requestHeadersToRemoves: ["RemoveMe"],
* requestHeadersToAdds: [{
* headerName: "AddMe",
* headerValue: "MyValue",
* replace: true,
* }],
* responseHeadersToRemoves: ["RemoveMe"],
* responseHeadersToAdds: [{
* headerName: "AddMe",
* headerValue: "MyValue",
* replace: false,
* }],
* },
* }],
* },
* }],
* }],
* tests: [{
* service: home.id,
* host: "hi.com",
* path: "/home",
* }],
* });
* ```
* ### Url Map Traffic Director Path Partial
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: _default.id,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "a description",
* defaultService: home.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* pathRules: [{
* paths: ["/home"],
* routeAction: {
* corsPolicy: {
* allowCredentials: true,
* allowHeaders: ["Allowed content"],
* allowMethods: ["GET"],
* allowOriginRegexes: ["abc.*"],
* allowOrigins: ["Allowed origin"],
* exposeHeaders: ["Exposed header"],
* maxAge: 30,
* disabled: false,
* },
* weightedBackendServices: [{
* backendService: home.id,
* weight: 400,
* headerAction: {
* requestHeadersToRemoves: ["RemoveMe"],
* requestHeadersToAdds: [{
* headerName: "AddMe",
* headerValue: "MyValue",
* replace: true,
* }],
* responseHeadersToRemoves: ["RemoveMe"],
* responseHeadersToAdds: [{
* headerName: "AddMe",
* headerValue: "MyValue",
* replace: false,
* }],
* },
* }],
* maxStreamDuration: {
* nanos: 500000,
* seconds: "9",
* },
* },
* }],
* }],
* tests: [{
* service: home.id,
* host: "hi.com",
* path: "/home",
* }],
* });
* ```
* ### Url Map Header Based Routing
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", {
* name: "health-check",
* requestPath: "/",
* checkIntervalSec: 1,
* timeoutSec: 1,
* });
* const _default = new gcp.compute.BackendService("default", {
* name: "default",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: defaultHttpHealthCheck.id,
* });
* const service_a = new gcp.compute.BackendService("service-a", {
* name: "service-a",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: defaultHttpHealthCheck.id,
* });
* const service_b = new gcp.compute.BackendService("service-b", {
* name: "service-b",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: defaultHttpHealthCheck.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "header-based routing example",
* defaultService: _default.id,
* hostRules: [{
* hosts: ["*"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: _default.id,
* routeRules: [
* {
* priority: 1,
* service: service_a.id,
* matchRules: [{
* prefixMatch: "/",
* ignoreCase: true,
* headerMatches: [{
* headerName: "abtest",
* exactMatch: "a",
* }],
* }],
* },
* {
* priority: 2,
* service: service_b.id,
* matchRules: [{
* ignoreCase: true,
* prefixMatch: "/",
* headerMatches: [{
* headerName: "abtest",
* exactMatch: "b",
* }],
* }],
* },
* ],
* }],
* });
* ```
* ### Url Map Parameter Based Routing
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", {
* name: "health-check",
* requestPath: "/",
* checkIntervalSec: 1,
* timeoutSec: 1,
* });
* const _default = new gcp.compute.BackendService("default", {
* name: "default",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: defaultHttpHealthCheck.id,
* });
* const service_a = new gcp.compute.BackendService("service-a", {
* name: "service-a",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: defaultHttpHealthCheck.id,
* });
* const service_b = new gcp.compute.BackendService("service-b", {
* name: "service-b",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: defaultHttpHealthCheck.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "parameter-based routing example",
* defaultService: _default.id,
* hostRules: [{
* hosts: ["*"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: _default.id,
* routeRules: [
* {
* priority: 1,
* service: service_a.id,
* matchRules: [{
* prefixMatch: "/",
* ignoreCase: true,
* queryParameterMatches: [{
* name: "abtest",
* exactMatch: "a",
* }],
* }],
* },
* {
* priority: 2,
* service: service_b.id,
* matchRules: [{
* ignoreCase: true,
* prefixMatch: "/",
* queryParameterMatches: [{
* name: "abtest",
* exactMatch: "b",
* }],
* }],
* },
* ],
* }],
* });
* ```
* ### Url Map Default Mirror Percent
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const mirror = new gcp.compute.BackendService("mirror", {
* name: "mirror",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "Test for default route action mirror percent",
* defaultService: home.id,
* defaultRouteAction: {
* requestMirrorPolicy: {
* backendService: mirror.id,
* mirrorPercent: 50,
* },
* },
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* }],
* });
* ```
* ### Url Map Path Matcher Default Mirror Percent
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const mirror = new gcp.compute.BackendService("mirror", {
* name: "mirror",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "Test for default route action mirror percent",
* defaultService: home.id,
* defaultRouteAction: {
* requestMirrorPolicy: {
* backendService: mirror.id,
* mirrorPercent: 50,
* },
* },
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* }],
* });
* ```
* ### Url Map Path Rule Mirror Percent
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const mirror = new gcp.compute.BackendService("mirror", {
* name: "mirror",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "Test for path matcher default route action mirror percent",
* defaultService: home.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* defaultRouteAction: {
* requestMirrorPolicy: {
* backendService: mirror.id,
* mirrorPercent: 75,
* },
* },
* }],
* });
* ```
* ### Url Map Route Rule Mirror Percent
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const home = new gcp.compute.BackendService("home", {
* name: "home",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const mirror = new gcp.compute.BackendService("mirror", {
* name: "mirror",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "Test for path rule route action mirror percent",
* defaultService: home.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: home.id,
* pathRules: [{
* paths: ["/home"],
* service: home.id,
* routeAction: {
* requestMirrorPolicy: {
* backendService: mirror.id,
* mirrorPercent: 25,
* },
* },
* }],
* }],
* });
* ```
* ### Url Map Test Headers
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const health_check = new gcp.compute.HealthCheck("health-check", {
* name: "health-check",
* timeoutSec: 1,
* checkIntervalSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* const backend = new gcp.compute.BackendService("backend", {
* name: "backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: health_check.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "URL map with test headers",
* defaultService: backend.id,
* tests: [
* {
* description: "Test with custom headers",
* host: "example.com",
* path: "/",
* service: backend.id,
* headers: [
* {
* name: "User-Agent",
* value: "TestBot/1.0",
* },
* {
* name: "X-Custom-Header",
* value: "test-value",
* },
* ],
* },
* {
* description: "Test with authorization headers",
* host: "api.example.com",
* path: "/v1/test",
* service: backend.id,
* headers: [
* {
* name: "Authorization",
* value: "Bearer token123",
* },
* {
* name: "Content-Type",
* value: "application/json",
* },
* ],
* },
* ],
* });
* ```
* ### Url Map Test Expected Output Url
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const health_check = new gcp.compute.HealthCheck("health-check", {
* name: "health-check",
* timeoutSec: 1,
* checkIntervalSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* const backend = new gcp.compute.BackendService("backend", {
* name: "backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: health_check.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "URL map with expected output URL tests",
* defaultService: backend.id,
* tests: [
* {
* description: "Test with expected output URL",
* host: "example.com",
* path: "/",
* service: backend.id,
* headers: [{
* name: "User-Agent",
* value: "TestBot/1.0",
* }],
* expectedOutputUrl: "http://example.com/",
* },
* {
* description: "Test API routing with expected output URL",
* host: "api.example.com",
* path: "/v1/users",
* service: backend.id,
* headers: [{
* name: "Authorization",
* value: "Bearer token123",
* }],
* expectedOutputUrl: "http://api.example.com/v1/users",
* },
* ],
* });
* ```
* ### Url Map Test Redirect Response Code
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const health_check = new gcp.compute.HealthCheck("health-check", {
* name: "health-check",
* timeoutSec: 1,
* checkIntervalSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* const backend = new gcp.compute.BackendService("backend", {
* name: "backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: health_check.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "URL map with redirect response code tests",
* defaultService: backend.id,
* hostRules: [{
* hosts: ["example.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: backend.id,
* pathRules: [{
* paths: ["/redirect/*"],
* urlRedirect: {
* hostRedirect: "newsite.com",
* pathRedirect: "/new-path/",
* httpsRedirect: true,
* redirectResponseCode: "MOVED_PERMANENTLY_DEFAULT",
* stripQuery: false,
* },
* }],
* }],
* tests: [
* {
* description: "Test redirect with expected response code",
* host: "example.com",
* path: "/redirect/old-page",
* headers: [{
* name: "Referer",
* value: "https://oldsite.com",
* }],
* expectedOutputUrl: "https://newsite.com/new-path/",
* expectedRedirectResponseCode: 301,
* },
* {
* description: "Test another redirect scenario",
* host: "example.com",
* path: "/redirect/another-page",
* headers: [{
* name: "User-Agent",
* value: "TestBot/1.0",
* }],
* expectedOutputUrl: "https://newsite.com/new-path/",
* expectedRedirectResponseCode: 301,
* },
* ],
* });
* ```
* ### Url Map Path Template Match
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HttpHealthCheck("default", {
* name: "health-check",
* requestPath: "/",
* checkIntervalSec: 1,
* timeoutSec: 1,
* });
* const cart_backend = new gcp.compute.BackendService("cart-backend", {
* name: "cart-service",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const user_backend = new gcp.compute.BackendService("user-backend", {
* name: "user-service",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const staticBucket = new gcp.storage.Bucket("static", {
* name: "static-asset-bucket",
* location: "US",
* });
* const static = new gcp.compute.BackendBucket("static", {
* name: "static-asset-backend-bucket",
* bucketName: staticBucket.name,
* enableCdn: true,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "a description",
* defaultService: static.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "mysite",
* }],
* pathMatchers: [{
* name: "mysite",
* defaultService: static.id,
* routeRules: [
* {
* matchRules: [{
* pathTemplateMatch: "/xyzwebservices/v2/xyz/users/{username=*}/carts/{cartid=**}",
* }],
* service: cart_backend.id,
* priority: 1,
* routeAction: {
* urlRewrite: {
* pathTemplateRewrite: "/{username}-{cartid}/",
* },
* },
* },
* {
* matchRules: [{
* pathTemplateMatch: "/xyzwebservices/v2/xyz/users/*/accountinfo/*",
* }],
* service: user_backend.id,
* priority: 2,
* },
* ],
* }],
* });
* ```
* ### Url Map Custom Error Response Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.HttpHealthCheck("default", {
* name: "health-check",
* requestPath: "/",
* checkIntervalSec: 1,
* timeoutSec: 1,
* });
* const example = new gcp.compute.BackendService("example", {
* name: "login",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* healthChecks: _default.id,
* });
* const errorBucket = new gcp.storage.Bucket("error", {
* name: "static-asset-bucket",
* location: "US",
* });
* const error = new gcp.compute.BackendBucket("error", {
* name: "error-backend-bucket",
* bucketName: errorBucket.name,
* enableCdn: true,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "a description",
* defaultService: example.id,
* defaultCustomErrorResponsePolicy: {
* errorResponseRules: [{
* matchResponseCodes: ["5xx"],
* path: "/internal_error.html",
* overrideResponseCode: 502,
* }],
* errorService: error.id,
* },
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "mysite",
* }],
* pathMatchers: [{
* name: "mysite",
* defaultService: example.id,
* defaultCustomErrorResponsePolicy: {
* errorResponseRules: [
* {
* matchResponseCodes: [
* "4xx",
* "5xx",
* ],
* path: "/login_error.html",
* overrideResponseCode: 404,
* },
* {
* matchResponseCodes: ["503"],
* path: "/bad_gateway.html",
* overrideResponseCode: 502,
* },
* ],
* errorService: error.id,
* },
* pathRules: [{
* paths: ["/private/*"],
* service: example.id,
* customErrorResponsePolicy: {
* errorResponseRules: [{
* matchResponseCodes: ["4xx"],
* path: "/login.html",
* overrideResponseCode: 401,
* }],
* errorService: error.id,
* },
* }],
* }],
* });
* ```
* ### Url Map Http Filter Configs
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultHealthCheck = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const _default = new gcp.compute.BackendService("default", {
* name: "default-backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* healthChecks: defaultHealthCheck.id,
* });
* const service_a = new gcp.compute.BackendService("service-a", {
* name: "service-a-backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* healthChecks: defaultHealthCheck.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "Test for httpFilterConfigs in route rules",
* defaultService: _default.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: _default.id,
* routeRules: [{
* priority: 1,
* service: service_a.id,
* matchRules: [{
* prefixMatch: "/",
* ignoreCase: true,
* }],
* httpFilterConfigs: [{
* filterName: "envoy.wasm",
* configTypeUrl: "type.googleapis.com/google.protobuf.Struct",
* config: JSON.stringify({
* name: "my-filter",
* root_id: "my_root_id",
* vm_config: {
* vm_id: "my_vm_id",
* runtime: "envoy.wasm.runtime.v8",
* code: {
* local: {
* inline_string: "const WASM_BINARY = '...'",
* },
* },
* },
* }),
* }],
* }],
* }],
* tests: [{
* service: _default.id,
* host: "mysite.com",
* path: "/",
* }],
* });
* ```
* ### Url Map Http Filter Metadata
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultHealthCheck = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* httpHealthCheck: {
* port: 80,
* },
* });
* const _default = new gcp.compute.BackendService("default", {
* name: "default-backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* healthChecks: defaultHealthCheck.id,
* });
* const service_a = new gcp.compute.BackendService("service-a", {
* name: "service-a-backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* healthChecks: defaultHealthCheck.id,
* });
* const service_b = new gcp.compute.BackendService("service-b", {
* name: "service-b-backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* healthChecks: defaultHealthCheck.id,
* });
* const urlmap = new gcp.compute.URLMap("urlmap", {
* name: "urlmap",
* description: "Test for httpFilterMetadata in route rules",
* defaultService: _default.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: _default.id,
* routeRules: [
* {
* priority: 1,
* service: service_a.id,
* matchRules: [{
* prefixMatch: "/",
* ignoreCase: true,
* }],
* httpFilterMetadatas: [{
* filterName: "envoy.wasm",
* configTypeUrl: "type.googleapis.com/google.protobuf.Struct",
* config: JSON.stringify({
* fields: {
* timeout: {
* string_value: "30s",
* },
* retries: {
* number_value: 3,
* },
* debug: {
* bool_value: true,
* },
* },
* }),
* }],
* },
* {
* priority: 2,
* service: service_b.id,
* matchRules: [{
* prefixMatch: "/api",
* ignoreCase: true,
* }],
* httpFilterMetadatas: [{
* filterName: "envoy.rate_limit",
* configTypeUrl: "type.googleapis.com/google.protobuf.Struct",
* config: JSON.stringify({
* fields: {
* requests_per_unit: {
* number_value: 100,
* },
* unit: {
* string_value: "MINUTE",
* },
* },
* }),
* }],
* },
* ],
* }],
* tests: [{
* service: _default.id,
* host: "mysite.com",
* path: "/",
* }],
* });
* ```
*
* ## Import
*
* UrlMap can be imported using any of these accepted formats:
*
* * `projects/{{project}}/global/urlMaps/{{name}}`
*
* * `{{project}}/{{name}}`
*
* * `{{name}}`
*
* When using the `pulumi import` command, UrlMap can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/uRLMap:URLMap default projects/{{project}}/global/urlMaps/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/uRLMap:URLMap default {{project}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/uRLMap:URLMap default {{name}}
* ```
*/
class URLMap extends pulumi.CustomResource {
/**
* Get an existing URLMap 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 URLMap(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of URLMap. 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'] === URLMap.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["creationTimestamp"] = state?.creationTimestamp;
resourceInputs["defaultCustomErrorResponsePolicy"] = state?.defaultCustomErrorResponsePolicy;
resourceInputs["defaultRouteAction"] = state?.defaultRouteAction;
resourceInputs["defaultService"] = state?.defaultService;
resourceInputs["defaultUrlRedirect"] = state?.defaultUrlRedirect;
resourceInputs["description"] = state?.description;
resourceInputs["fingerprint"] = state?.fingerprint;
resourceInputs["headerAction"] = state?.headerAction;
resourceInputs["hostRules"] = state?.hostRules;
resourceInputs["mapId"] = state?.mapId;
resourceInputs["name"] = state?.name;
resourceInputs["pathMatchers"] = state?.pathMatchers;
resourceInputs["project"] = state?.project;
resourceInputs["selfLink"] = state?.selfLink;
resourceInputs["tests"] = state?.tests;
}
else {
const args = argsOrState;
resourceInputs["defaultCustomErrorResponsePolicy"] = args?.defaultCustomErrorResponsePolicy;
resourceInputs["defaultRouteAction"] = args?.defaultRouteAction;
resourceInputs["defaultService"] = args?.defaultService;
resourceInputs["defaultUrlRedirect"] = args?.defaultUrlRedirect;
resourceInputs["description"] = args?.description;
resourceInputs["headerAction"] = args?.headerAction;
resourceInputs["hostRules"] = args?.hostRules;
resourceInputs["name"] = args?.name;
resourceInputs["pathMatchers"] = args?.pathMatchers;
resourceInputs["project"] = args?.project;
resourceInputs["tests"] = args?.tests;
resourceInputs["creationTimestamp"] = undefined /*out*/;
resourceInputs["fingerprint"] = undefined /*out*/;
resourceInputs["mapId"] = undefined /*out*/;
resourceInputs["selfLink"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(URLMap.__pulumiType, name, resourceInputs, opts);
}
}
exports.URLMap = URLMap;
/** @internal */
URLMap.__pulumiType = 'gcp:compute/uRLMap:URLMap';
//# sourceMappingURL=urlmap.js.map