The command:

gcloud compute forwarding-rules create myproxyforwardrule --ip-protocol TCP \
--ports 80-443 --target-instance proxygorod --region us-central1

as well as:

gcloud compute forwarding-rules create myproxyforwardrule --ip-protocol TCP \
--ports 80-443 --target-instance https://www.googleapis.com/compute/v1/projects/<project_name>/zones/us-central1-c/targetInstances/proxygorod \
--region https://www.googleapis.com/compute/v1/projects/<project_name>/regions/us-central1

Both return:

ERROR: (gcloud.compute.forwarding-rules.create) Could not fetch resource:
 - The resource 'projects/<project_name>/zones/us-central1-c/targetInstances/proxygorod' was not found

Region: us-central1-c
Instace: proxygorod f1-micro

What may be wrong?

What I have tried:

  1. gcloud init
  2. gcloud auth login
  3. Renaming instance

It looks like you may have missed a step before issuing the command to create the forwarding rule.

The reason the command is saying it can't find the resource is because the --target-instance flag requires a target-instance resource to be configured first.

You can use your existing instance ('proxygorod') for this, and assign it with a newly created target-instance resource.

You can create a target instance resource and assign it to an instance by running the following:

gcloud compute target-instances create NAME --instance=INSTANCE--zone=ZONE

So in your specific case you could run something like:

gcloud compute target-instances create proxygorod-target --instance=proxygorod--zone=us-central1-c  

Once the target-instance has been configured, and presuming you used the same name for the target instance resource as in the above command, you would then be able to create the forwarding rule by issuing the following:

gcloud compute forwarding-rules create myproxyforwardrule --ip-protocol TCP --ports 80-443 --target-instance proxygorod-target --region=us-central1

There is some further information about creating target instances here.

  • However on my VM instance details page I still see "IP forwarding: OFF" in Network interfaces – ilyaigpetrov Dec 12 '17 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.