UNPKG

@pulumi/gcp

Version:

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

1,437 lines • 57.5 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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/*&#47;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}} * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: URLMapState, opts?: pulumi.CustomResourceOptions): URLMap; /** * 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: any): obj is URLMap; /** * Creation timestamp in RFC3339 text format. */ readonly creationTimestamp: pulumi.Output<string>; /** * defaultCustomErrorResponsePolicy specifies how the Load Balancer returns error responses when BackendService or BackendBucket responds with an error. * This policy takes effect at the PathMatcher level and applies only when no policy has been defined for the error code at lower levels like RouteRule and PathRule within this PathMatcher. If an error code does not have a policy defined in defaultCustomErrorResponsePolicy, then a policy defined for the error code in UrlMap.defaultCustomErrorResponsePolicy takes effect. * For example, consider a UrlMap with the following configuration: * UrlMap.defaultCustomErrorResponsePolicy is configured with policies for 5xx and 4xx errors * A RouteRule for /coming_soon/ is configured for the error code 404. * If the request is for www.myotherdomain.com and a 404 is encountered, the policy under UrlMap.defaultCustomErrorResponsePolicy takes effect. If a 404 response is encountered for the request www.example.com/current_events/, the pathMatcher's policy takes effect. If however, the request for www.example.com/coming_soon/ encounters a 404, the policy in RouteRule.customErrorResponsePolicy takes effect. If any of the requests in this example encounter a 500 error code, the policy at UrlMap.defaultCustomErrorResponsePolicy takes effect. * When used in conjunction with pathMatcher.defaultRouteAction.retryPolicy, retries take precedence. Only once all retries are exhausted, the defaultCustomErrorResponsePolicy is applied. While attempting a retry, if load balancer is successful in reaching the service, the defaultCustomErrorResponsePolicy is ignored and the response from the service is returned to the client. * defaultCustomErrorResponsePolicy is supported only for global external Application Load Balancers. * Structure is documented below. */ readonly defaultCustomErrorResponsePolicy: pulumi.Output<outputs.compute.URLMapDefaultCustomErrorResponsePolicy | undefined>; /** * defaultRouteAction takes effect when none of the hostRules match. The load balancer performs advanced routing actions * like URL rewrites, header transformations, etc. prior to forwarding the request to the selected backend. * If defaultRouteAction specifies any weightedBackendServices, defaultService must not be set. Conversely if defaultService * is set, defaultRouteAction cannot contain any weightedBackendServices. * Only one of defaultRouteAction or defaultUrlRedirect must be set. * Structure is documented below. */ readonly defaultRouteAction: pulumi.Output<outputs.compute.URLMapDefaultRouteAction | undefined>; /** * The backend service or backend bucket to use when none of the given rules match. */ readonly defaultService: pulumi.Output<string | undefined>; /** * When none of the specified hostRules match, the request is redirected to a URL specified * by defaultUrlRedirect. If defaultUrlRedirect is specified, defaultService or * defaultRouteAction must not be set. * Structure is documented below. */ readonly defaultUrlRedirect: pulumi.Output<outputs.compute.URLMapDefaultUrlRedirect | undefined>; /** * An optional description of this resource. Provide this property when you create * the resource. */ readonly description: pulumi.Output<string | undefined>; /** * Fingerprint of this resource. A hash of the contents stored in this object. This * field is used in optimistic locking. */ readonly fingerprint: pulumi.Output<string>; /** * Specifies changes to request and response headers that need to take effect for * the selected backendService. The headerAction specified here take effect after * headerAction specified under pathMatcher. * Structure is documented below. */ readonly headerAction: pulumi.Output<outputs.compute.URLMapHeaderAction | undefined>; /** * The list of HostRules to use against the URL. * Structure is documented below. */ readonly hostRules: pulumi.Output<outputs.compute.URLMapHostRule[] | undefined>; /** * The unique identifier for the resource. */ readonly mapId: pulumi.Output<number>; /** * Name of the resource. Provided by the client when the resource is created. The * name must be 1-63 characters long, and comply with RFC1035. Specifically, the * name must be 1-63 characters long and match the regular expression * `a-z?` which means the first character must be a lowercase * letter, and all following characters must be a dash, lowercase letter, or digit, * except the last character, which cannot be a dash. */ readonly name: pulumi.Output<string>; /** * The list of named PathMatchers to use against the URL. * Structure is documented below. */ readonly pathMatchers: pulumi.Output<outputs.compute.URLMapPathMatcher[] | undefined>; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ readonly project: pulumi.Output<string>; /** * The URI of the created resource. */ readonly selfLink: pulumi.Output<string>; /** * The list of expected URL mapping tests. Request to update this UrlMap will * succeed only if all of the test cases pass. You can specify a maximum of 100 * tests per UrlMap. * Structure is documented below. */ readonly tests: pulumi.Output<outputs.compute.URLMapTest[] | undefined>; /** * Create a URLMap resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: URLMapArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering URLMap resources. */ export interface URLMapState { /** * Creation timestamp in RFC3339 text format. */ creationTimestamp?: pulumi.Input<string>; /** * defaultCustomErrorResponsePolicy specifies how the Load Balancer returns error responses when BackendService or BackendBucket responds with an error. * This policy takes effect at the PathMatcher level and applies only when no policy has been defined for the error code at lower levels like RouteRule and PathRule within this PathMatcher. If an error code does not have a policy defined in defaultCustomErrorResponsePolicy, then a policy defined for the error code in UrlMap.defaultCustomErrorResponsePolicy takes effect. * For example, consider a UrlMap with the following configuration: * UrlMap.defaultCustomErrorResponsePolicy is configured with policies for 5xx and 4xx errors * A RouteRule for /coming_soon/ is configured for the error code 404. * If the request is for www.myotherdomain.com and a 404 is encountered, the policy under UrlMap.defaultCustomErrorResponsePolicy takes effect. If a 404 response is encountered for the request www.example.com/current_events/, the pathMatcher's policy takes effect. If however, the request for www.example.com/coming_soon/ encounters a 404, the policy in RouteRule.customErrorResponsePolicy takes effect. If any of the requests in this example encounter a 500 error code, the policy at UrlMap.defaultCustomErrorResponsePolicy takes effect. * When used in conjunction with pathMatcher.defaultRouteAction.retryPolicy, retries take precedence. Only once all retries are exhausted, the defaultCustomErrorResponsePolicy is applied. While attempting a retry, if load balancer is successful in reaching the service, the defaultCustomErrorResponsePolicy is ignored and the response from the service is returned to the client. * defaultCustomErrorResponsePolicy is supported only for global external Application Load Balancers. * Structure is documented below. */ defaultCustomErrorResponsePolicy?: pulumi.Input<inputs.compute.URLMapDefaultCustomErrorResponsePolicy>; /** * defaultRouteAction takes effect when none of the hostRules match. The load balancer performs advanced routing actions * like URL rewrites, header transformations, etc. prior to forwarding the request to the selected backend. * If defaultRouteAction specifies any weightedBackendServices, defaultService must not be set. Conversely if defaultService * is set, defaultRouteAction cannot contain any weightedBackendServices. * Only one of defaultRouteAction or defaultUrlRedirect must be set. * Structure is documented below. */ defaultRouteAction?: pulumi.Input<inputs.compute.URLMapDefaultRouteAction>; /** * The backend service or backend bucket to use when none of the given rules match. */ defaultService?: pulumi.Input<string>; /** * When none of the specified hostRules match, the request is redirected to a URL specified * by defaultUrlRedirect. If defaultUrlRedirect is specified, defaultService