I want to add path matching rules to a url map in google compute engine. Here is my command:
gcloud compute url-maps add-path-matcher myproject-url-map --default-service \
backend-service-wordpress --path-matcher-name root --path-rules "/=backend-\
service-wordpress,/features/=backend-service-wordpress,/pricing/=backend-\
service-wordpress,/blog/=backend-service-wordpress,/\?*=backend-service-wordpress"
it throws this error message:
ERROR: (gcloud.compute.url-maps.add-path-matcher) There was a problem modifying the resource:
- Invalid value for field 'resource': ''. Invalid path pattern
I don't think I have defined a blank resource in this command line.
I have to quote the parameters to --path-rules
in a pair of quotes because zsh will complaint otherwise.
This is the first rule I want to define. Following this I am going to add a rule to map all /*
to another backend service, like so:
gcloud compute url-maps add-path-matcher myproject-url-map --default-service \
backend-service-app --path-matcher-name others --path-rules "/*=backend-service-app"
What does this error message? What's wrong with my command?
Best Answer
I suspect it is something to do with using both double quotes and backslash quotes for the argument to --path-rules. In particular, you don't need the backslash to quote the question mark. Note the output from:
Similarly, the newlines inside the double quotes don't need a backslash unless you have the csh_junkie_quotes option set.
There's various ways zsh can help you to quote words automatically. One way is to perhaps try binding a key to quote-region. This will quote the region (emacs mode) or visual selection (vi mode).