Google Cloud Global Forwarding: Invalid value for field resource.IPAddress

Viewed 8486

I am trying to implement https support for my GCP VM. For the purpose, I created all the load balancing components i.e. instance group, health check, backend service, url map & target proxy. All were created without error. However now when I am creating a global forwarding rule for the final step, I am getting the following error:

ERROR: (gcloud.compute.forwarding-rules.create) Could not fetch resource: - Invalid value for field 'resource.IPAddress': '35.xxx.xxx.xxx'. Invalid IP address specified.

I am using the following command:

gcloud compute forwarding-rules create fa-global-fwding-rule-1 --target-https-proxy=fa-https-proxy-1 --ports=443  --global --address=35.xxx.xxx.xxx

(IP add digits masked with xxx)

What am I missing?

I already have a working VM instance through http where I had promoted its ephemeral address to a static address (above is the same address 35.xxx.xxx.xxx)

Also once I implement https support, I want the http connect to continue working as well so that my existing apis are not disturbed until I move them to https

Any advice/help?

2 Answers

GCPs Load Balancer does not check to see if the static IP you picked was regional or global. If you accidentally reserved a "regional" IP instead of a "global" IP, it throws that silly error:

Invalid value for field 'resource.IPAddress': '35.xxx.xxx.xxx'. Invalid IP address specified.

I don’t find any issues with your command, this kind of error is mostly observed due to IP conflict if the specified IP address is in use or not available. The Forwarding Rules map the IP address for your load balancer to the Target Proxy that will handle the requests.So first you will need to create your IP address though. Using this command: $gcloud compute addresses create my-address --global

And then create a forwarding rule. You will need a global, rather than regional, IP address for your HTTPS load balancer. Using this command :

$gcloud compute forwarding-rules create my-https-forwarding-rule --global --address 123.123.123.123 --ip-protocol TCP --port-range 443 --target-https-proxy my-https-proxy

Can you confirm if you are using a global or a regional IP address?

For HTTP, You need to create a totally separate Target HTTP Proxy and Forwarding Rule for HTTP. You essentially need to have two load balancers to handle the traffic, and then actually redirect users in your application. Notice that we put the same IP address in for the HTTP Forwarding Rule. This makes it so that we can listen on port 80 and on port 443 at our IP address.

Related