Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

HTTPS Load Balancer add host path rules using gcloud

Hi All,

I have a requirement to create / updated the HTTPS load balancer dynamically with different host path rules (Serverless NEG as backends)

 

I have created a url-map for the 1st time using below command 

gcloud compute url-maps add-path-matcher test-lb --path-matcher-name=test-path-match --default-service=my-neg-be --path-rules="/path_1=my-neg-be,/path_1/*=my-neg-be" --new-hosts=test.mydomain.com

Now I wanted to add subsequent path rules dynamically using gcloud during a deployment. So have I am unable to find a gcloud command qcloud command which can be used to add subsequent path rules.

Just want to check if anyone have thoughts around this. thank you.

 

Regards,

Pradeep

Solved Solved
0 6 3,879
1 ACCEPTED SOLUTION

Thanks for clarifying the requirement, Pradeep! I agree that the interactive approach offered by `gcloud compute url-maps edit` won't be useful for automated/programmatic updates. I wonder whether you could use a client library  (examples: https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/update#examples)

View solution in original post

6 REPLIES 6

Hi @dumpalap ,

I'm not quite sure what you meant by adding path rules "dynamically".

But if the intent is to edit the URL map to add or change the path rules, you might find this command useful: 

gcloud compute url-maps edit <map>

The command opens the map in a text editor. Make the necessary changes and save them.

Doc: https://cloud.google.com/sdk/gcloud/reference/compute/url-maps/edit

 

Hi @kumards ,

Thanks for the response. I have gone thru the command which you have given. This opens a editor to add the rules. My scenario will run in a release pipeline and I can not take an approach of interactive editor.

One option I am thinking is edit the yaml content in command line and import it. But want to check if there is any better way.

 

Regards,

Pradeep

Thanks for clarifying the requirement, Pradeep! I agree that the interactive approach offered by `gcloud compute url-maps edit` won't be useful for automated/programmatic updates. I wonder whether you could use a client library  (examples: https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/update#examples)

Hi @kumards  ,

Thanks for providing the details. I am trying with client library and it looks like we can achieve this with some tweaking. But I am keep getting the error in update action.

Action:

update_url_map_request = service.urlMaps().update(project=project, urlMap=url_map, body='urlMapJsonData.json')
update_url_map_request = update_url_map_request.execute()
 
Error:

"Required field 'resource.fingerprint' not specified". Details: "[{'message': "Required field 'resource.fingerprint' not specified", 'domain': 'global', 'reason': 'required'}]">

My JSON request is having fingerprint in it. please see the below screen print.

dumpalap_0-1645068921715.png

 

Please let me know if you have any clue ?

Regards,

Pradeep

 

Hi @kumards  , please ignore my earlier message.