Expand description
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.
§Example Usage
§Region Url Map Basic
ⓘ
use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
let default = region_health_check::create(
"default",
RegionHealthCheckArgs::builder()
.check_interval_sec(1)
.http_health_check(
RegionHealthCheckHttpHealthCheck::builder()
.port(80)
.requestPath("/")
.build_struct(),
)
.name("health-check")
.region("us-central1")
.timeout_sec(1)
.build_struct(),
);
let home = region_backend_service::create(
"home",
RegionBackendServiceArgs::builder()
.health_checks("${default.id}")
.load_balancing_scheme("INTERNAL_MANAGED")
.name("home")
.protocol("HTTP")
.region("us-central1")
.timeout_sec(10)
.build_struct(),
);
let login = region_backend_service::create(
"login",
RegionBackendServiceArgs::builder()
.health_checks("${default.id}")
.load_balancing_scheme("INTERNAL_MANAGED")
.name("login")
.protocol("HTTP")
.region("us-central1")
.timeout_sec(10)
.build_struct(),
);
let regionurlmap = region_url_map::create(
"regionurlmap",
RegionUrlMapArgs::builder()
.default_service("${home.id}")
.description("a description")
.host_rules(
vec![
RegionUrlMapHostRule::builder().hosts(vec!["mysite.com",])
.pathMatcher("allpaths").build_struct(),
],
)
.name("regionurlmap")
.path_matchers(
vec![
RegionUrlMapPathMatcher::builder().defaultService("${home.id}")
.name("allpaths")
.pathRules(vec![RegionUrlMapPathMatcherPathRule::builder()
.paths(vec!["/home",]).service("${home.id}").build_struct(),
RegionUrlMapPathMatcherPathRule::builder().paths(vec!["/login",])
.service("${login.id}").build_struct(),]).build_struct(),
],
)
.region("us-central1")
.tests(
vec![
RegionUrlMapTest::builder().host("hi.com").path("/home")
.service("${home.id}").build_struct(),
],
)
.build_struct(),
);
}
§Region Url Map Default Route Action
resources:
regionurlmap:
type: gcp:compute:RegionUrlMap
properties:
region: us-central1
name: regionurlmap
description: a description
defaultRouteAction:
retryPolicy:
retryConditions:
- 5xx
- gateway-error
numRetries: 3
perTryTimeout:
seconds: 0
nanos: 500
requestMirrorPolicy:
backendService: ${home.id}
weightedBackendServices:
- backendService: ${login.id}
weight: 200
headerAction:
requestHeadersToAdds:
- headerName: foo-request-1
headerValue: bar
replace: true
requestHeadersToRemoves:
- fizz
responseHeadersToAdds:
- headerName: foo-response-1
headerValue: bar
replace: true
responseHeadersToRemoves:
- buzz
- backendService: ${home.id}
weight: 100
headerAction:
requestHeadersToAdds:
- headerName: foo-request-1
headerValue: bar
replace: true
- headerName: foo-request-2
headerValue: bar
replace: true
requestHeadersToRemoves:
- fizz
responseHeadersToAdds:
- headerName: foo-response-2
headerValue: bar
replace: true
- headerName: foo-response-1
headerValue: bar
replace: true
responseHeadersToRemoves:
- buzz
urlRewrite:
hostRewrite: dev.example.com
pathPrefixRewrite: /v1/api/
corsPolicy:
disabled: false
allowCredentials: true
allowHeaders:
- foobar
allowMethods:
- GET
- POST
allowOrigins:
- example.com
exposeHeaders:
- foobar
maxAge: 60
faultInjectionPolicy:
delay:
fixedDelay:
seconds: 0
nanos: 500
percentage: 0.5
abort:
httpStatus: 500
percentage: 0.5
timeout:
seconds: 0
nanos: 500
hostRules:
- hosts:
- mysite.com
pathMatcher: allpaths
pathMatchers:
- name: allpaths
defaultService: ${home.id}
pathRules:
- paths:
- /home
service: ${home.id}
- paths:
- /login
service: ${login.id}
tests:
- service: ${home.id}
host: hi.com
path: /home
login:
type: gcp:compute:RegionBackendService
properties:
region: us-central1
name: login
protocol: HTTP
loadBalancingScheme: INTERNAL_MANAGED
timeoutSec: 10
healthChecks: ${default.id}
home:
type: gcp:compute:RegionBackendService
properties:
region: us-central1
name: home
protocol: HTTP
loadBalancingScheme: INTERNAL_MANAGED
timeoutSec: 10
healthChecks: ${default.id}
default:
type: gcp:compute:RegionHealthCheck
properties:
region: us-central1
name: health-check
checkIntervalSec: 1
timeoutSec: 1
httpHealthCheck:
port: 80
requestPath: /
§Region Url Map L7 Ilb Path
resources:
regionurlmap:
type: gcp:compute:RegionUrlMap
properties:
name: regionurlmap
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
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: 7.5e+08
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
home:
type: gcp:compute:RegionBackendService
properties:
name: home
protocol: HTTP
timeoutSec: 10
healthChecks: ${default.id}
loadBalancingScheme: INTERNAL_MANAGED
default:
type: gcp:compute:RegionHealthCheck
properties:
name: health-check
httpHealthCheck:
port: 80
§Region Url Map L7 Ilb Path Partial
resources:
regionurlmap:
type: gcp:compute:RegionUrlMap
properties:
name: regionurlmap
description: a description
defaultService: ${home.id}
hostRules:
- hosts:
- mysite.com
pathMatcher: allpaths
pathMatchers:
- name: allpaths
defaultService: ${home.id}
pathRules:
- paths:
- /home
routeAction:
retryPolicy:
numRetries: 4
perTryTimeout:
seconds: 30
retryConditions:
- 5xx
- deadline-exceeded
timeout:
seconds: 20
nanos: 7.5e+08
urlRewrite:
hostRewrite: dev.example.com
pathPrefixRewrite: /v1/api/
weightedBackendServices:
- backendService: ${home.id}
weight: 400
headerAction:
responseHeadersToAdds:
- headerName: AddMe
headerValue: MyValue
replace: false
tests:
- service: ${home.id}
host: hi.com
path: /home
home:
type: gcp:compute:RegionBackendService
properties:
name: home
protocol: HTTP
timeoutSec: 10
healthChecks: ${default.id}
loadBalancingScheme: INTERNAL_MANAGED
default:
type: gcp:compute:RegionHealthCheck
properties:
name: health-check
httpHealthCheck:
port: 80
§Region Url Map L7 Ilb Route
ⓘ
use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
let default = region_health_check::create(
"default",
RegionHealthCheckArgs::builder()
.http_health_check(
RegionHealthCheckHttpHealthCheck::builder().port(80).build_struct(),
)
.name("health-check")
.build_struct(),
);
let home = region_backend_service::create(
"home",
RegionBackendServiceArgs::builder()
.health_checks("${default.id}")
.load_balancing_scheme("INTERNAL_MANAGED")
.name("home")
.protocol("HTTP")
.timeout_sec(10)
.build_struct(),
);
let regionurlmap = region_url_map::create(
"regionurlmap",
RegionUrlMapArgs::builder()
.default_service("${home.id}")
.description("a description")
.host_rules(
vec![
RegionUrlMapHostRule::builder().hosts(vec!["mysite.com",])
.pathMatcher("allpaths").build_struct(),
],
)
.name("regionurlmap")
.path_matchers(
vec![
RegionUrlMapPathMatcher::builder().defaultService("${home.id}")
.name("allpaths")
.routeRules(vec![RegionUrlMapPathMatcherRouteRule::builder()
.headerAction(RegionUrlMapPathMatcherRouteRuleHeaderAction::builder()
.requestHeadersToAdds(vec![RegionUrlMapPathMatcherRouteRuleHeaderActionRequestHeadersToAdd::builder()
.headerName("AddSomethingElse").headerValue("MyOtherValue")
.replace(true).build_struct(),])
.requestHeadersToRemoves(vec!["RemoveMe2",])
.responseHeadersToAdds(vec![RegionUrlMapPathMatcherRouteRuleHeaderActionResponseHeadersToAdd::builder()
.headerName("AddMe").headerValue("MyValue").replace(false)
.build_struct(),]).responseHeadersToRemoves(vec!["RemoveMe3",])
.build_struct())
.matchRules(vec![RegionUrlMapPathMatcherRouteRuleMatchRule::builder()
.fullPathMatch("a full path")
.headerMatches(vec![RegionUrlMapPathMatcherRouteRuleMatchRuleHeaderMatch::builder()
.exactMatch("match this exactly").headerName("someheader")
.invertMatch(true).build_struct(),]).ignoreCase(true)
.metadataFilters(vec![RegionUrlMapPathMatcherRouteRuleMatchRuleMetadataFilter::builder()
.filterLabels(vec![RegionUrlMapPathMatcherRouteRuleMatchRuleMetadataFilterFilterLabel::builder()
.name("PLANET").value("MARS").build_struct(),])
.filterMatchCriteria("MATCH_ANY").build_struct(),])
.queryParameterMatches(vec![RegionUrlMapPathMatcherRouteRuleMatchRuleQueryParameterMatch::builder()
.name("a query parameter").presentMatch(true).build_struct(),])
.build_struct(),]).priority(1)
.urlRedirect(RegionUrlMapPathMatcherRouteRuleUrlRedirect::builder()
.hostRedirect("A host").httpsRedirect(false)
.pathRedirect("some/path").redirectResponseCode("TEMPORARY_REDIRECT")
.stripQuery(true).build_struct()).build_struct(),]).build_struct(),
],
)
.tests(
vec![
RegionUrlMapTest::builder().host("hi.com").path("/home")
.service("${home.id}").build_struct(),
],
)
.build_struct(),
);
}
§Region Url Map L7 Ilb Route Partial
ⓘ
use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
let default = region_health_check::create(
"default",
RegionHealthCheckArgs::builder()
.http_health_check(
RegionHealthCheckHttpHealthCheck::builder().port(80).build_struct(),
)
.name("health-check")
.build_struct(),
);
let home = region_backend_service::create(
"home",
RegionBackendServiceArgs::builder()
.health_checks("${default.id}")
.load_balancing_scheme("INTERNAL_MANAGED")
.name("home")
.protocol("HTTP")
.timeout_sec(10)
.build_struct(),
);
let regionurlmap = region_url_map::create(
"regionurlmap",
RegionUrlMapArgs::builder()
.default_service("${home.id}")
.description("a description")
.host_rules(
vec![
RegionUrlMapHostRule::builder().hosts(vec!["mysite.com",])
.pathMatcher("allpaths").build_struct(),
],
)
.name("regionurlmap")
.path_matchers(
vec![
RegionUrlMapPathMatcher::builder().defaultService("${home.id}")
.name("allpaths")
.routeRules(vec![RegionUrlMapPathMatcherRouteRule::builder()
.headerAction(RegionUrlMapPathMatcherRouteRuleHeaderAction::builder()
.requestHeadersToRemoves(vec!["RemoveMe2",]).build_struct())
.matchRules(vec![RegionUrlMapPathMatcherRouteRuleMatchRule::builder()
.fullPathMatch("a full path")
.headerMatches(vec![RegionUrlMapPathMatcherRouteRuleMatchRuleHeaderMatch::builder()
.exactMatch("match this exactly").headerName("someheader")
.invertMatch(true).build_struct(),])
.queryParameterMatches(vec![RegionUrlMapPathMatcherRouteRuleMatchRuleQueryParameterMatch::builder()
.name("a query parameter").presentMatch(true).build_struct(),])
.build_struct(),]).priority(1).service("${home.id}")
.build_struct(),]).build_struct(),
],
)
.tests(
vec![
RegionUrlMapTest::builder().host("hi.com").path("/home")
.service("${home.id}").build_struct(),
],
)
.build_struct(),
);
}
§Region Url Map Path Template Match
resources:
urlmap:
type: gcp:compute:RegionUrlMap
properties:
region: us-central1
name: urlmap
description: a description
defaultService: ${["home-backend"].id}
hostRules:
- hosts:
- mysite.com
pathMatcher: mysite
pathMatchers:
- name: mysite
defaultService: ${["home-backend"].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
home-backend:
type: gcp:compute:RegionBackendService
properties:
region: us-central1
name: home-service
portName: http
protocol: HTTP
timeoutSec: 10
loadBalancingScheme: EXTERNAL_MANAGED
healthChecks: ${default.id}
cart-backend:
type: gcp:compute:RegionBackendService
properties:
region: us-central1
name: cart-service
portName: http
protocol: HTTP
timeoutSec: 10
loadBalancingScheme: EXTERNAL_MANAGED
healthChecks: ${default.id}
user-backend:
type: gcp:compute:RegionBackendService
properties:
region: us-central1
name: user-service
portName: http
protocol: HTTP
timeoutSec: 10
loadBalancingScheme: EXTERNAL_MANAGED
healthChecks: ${default.id}
default:
type: gcp:compute:RegionHealthCheck
properties:
region: us-central1
name: health-check
checkIntervalSec: 1
timeoutSec: 1
httpHealthCheck:
port: 80
requestPath: /
§Import
RegionUrlMap can be imported using any of these accepted formats:
-
projects/{{project}}/regions/{{region}}/urlMaps/{{name}}
-
{{project}}/{{region}}/{{name}}
-
{{region}}/{{name}}
-
{{name}}
When using the pulumi import
command, RegionUrlMap can be imported using one of the formats above. For example:
$ pulumi import gcp:compute/regionUrlMap:RegionUrlMap default projects/{{project}}/regions/{{region}}/urlMaps/{{name}}
$ pulumi import gcp:compute/regionUrlMap:RegionUrlMap default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:compute/regionUrlMap:RegionUrlMap default {{region}}/{{name}}
$ pulumi import gcp:compute/regionUrlMap:RegionUrlMap default {{name}}
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments