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:
gcloud init
gcloud auth login
- Renaming instance
Best Answer
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:
So in your specific case you could run something like:
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:
There is some further information about creating target instances here.