gcloud compute url-maps add-path-matcher Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud compute url-maps add-path-matcher - add a path matcher to a URL map
- SYNOPSIS
gcloud compute url-maps add-path-matcherURL_MAP--path-matcher-name=PATH_MATCHER_NAME(--default-backend-bucket=DEFAULT_BACKEND_BUCKET|--default-service=DEFAULT_SERVICE)[--backend-bucket-path-rules=PATH=BUCKET,[PATH=BUCKET,…]][--backend-service-path-rules=PATH=SERVICE,[…]][--delete-orphaned-path-matcher][--description=DESCRIPTION][--path-rules=PATH=SERVICE,[…]][--existing-host=EXISTING_HOST|--new-hosts=NEW_HOST,[NEW_HOST,…]][--global|--region=REGION][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
gcloud compute url-maps add-path-matcheris used to add a pathmatcher to a URL map. A path matcher maps HTTP request paths to backend servicesor backend buckets. Each path matcher must be referenced by at least one hostrule. This command can create a new host rule through the--new-hostsflag or it can reconfigure an existing host rule topoint to the newly added path matcher using--existing-host. In thelatter case, if a path matcher is orphaned as a result of the operation, thiscommand will fail unless--delete-orphaned-path-matcherisprovided. Path matcher constraints can be foundhere.- EXAMPLES
- To create a rule for mapping the path
/search/*to the hypotheticalsearch-service,/static/*to thestatic-bucketbackend bucket and/images/*to theimages-serviceunder the hostsexample.comand*.example.com, run:gcloudcomputeurl-mapsadd-path-matcherMY-URL-MAP--path-matcher-name=MY-MATCHER--default-service=MY-DEFAULT-SERVICE--backend-service-path-rules='/search/*=search_service,/images/*=images-service'--backend-bucket-path-rules='/static/*=static-bucket'--new-hosts=example.com'*.example.com'Note that a default service or default backend bucket must be provided to handlepaths for which there is no mapping.
- POSITIONAL ARGUMENTS
URL_MAP- Name of the URL map to operate on.
- REQUIRED FLAGS
--path-matcher-name=PATH_MATCHER_NAME- The name to assign to the path matcher.
- Exactly one of these must be specified:
--default-backend-bucket=DEFAULT_BACKEND_BUCKET- A backend bucket that will be used for requests that the path matcher cannotmatch. Exactly one of --default-service or --default-backend-bucket is required.
--default-service=DEFAULT_SERVICE- A backend service that will be used for requests that the path matcher cannotmatch. Exactly one of --default-service or --default-backend-bucket is required.
- OPTIONAL FLAGS
--backend-bucket-path-rules=PATH=BUCKET,[PATH=BUCKET,…]- Rules for mapping request paths to backend buckets.
--backend-service-path-rules=PATH=SERVICE,[…]- Rules for mapping request paths to services.
--delete-orphaned-path-matcher- If provided and a path matcher is orphaned as a result of this command, thecommand removes the orphaned path matcher instead of failing.
--description=DESCRIPTION- An optional, textual description for the path matcher.
--path-rules=PATH=SERVICE,[…]- Rules for mapping request paths to services.
- At most one of these can be specified:
--existing-host=EXISTING_HOST- An existing host rule to tie the new path matcher to. Although host rules cancontain more than one host, only a single host is needed to uniquely identifythe host rule.
--new-hosts=NEW_HOST,[NEW_HOST,…]- If specified, a new host rule with the given hosts is created and the pathmatcher is tied to the new host rule.
- At most one of these can be specified:
--global- If set, the URL map is global.
--region=REGION- Region of the URL map to operate on. If not specified, you might be prompted toselect a region (interactive mode only).
To avoid prompting when this flag is omitted, you can set the
property:compute/regiongcloudconfigsetcompute/regionREGIONA list of regions can be fetched by running:
gcloudcomputeregionslistTo unset the property, run:
gcloudconfigunsetcompute/regionAlternatively, the region can be stored in the environment variable
.CLOUDSDK_COMPUTE_REGION
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- These variants are also available:
gcloudalphacomputeurl-mapsadd-path-matchergcloudbetacomputeurl-mapsadd-path-matcher
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-07 UTC.