'Gcloud could not fetch resource: Specified IP address is not allocated to the project or does not belong to the specified scope
I'm trying to migrate a VM on GCP from one project to another. I succeeded until a point where it came to transferring the static IP address.
I detached it from the old VM and then deleted/released it. I went to the new project and attempted to create the new instance with the command:
gcloud compute instances create <name> --address x.x.x.x
And got error:
ERROR: (gcloud.compute.addresses.create) Could not fetch resource:
- Invalid value for field 'resource.address': 'x.x.x.x'. Specified
IP address is not allocated to the project or does n
ot belong to the specified scope.
I thought instead maybe I needed to reserve the IP address first, and tried:
gcloud compute addresses create <name> --addresses
x.x.x.x --region us-east1
And from that, got essentially the same thing --
ERROR: (gcloud.compute.addresses.create) Could not fetch
resource:- Invalid value for field 'resource.address': 'x.x.x.x'.
Specified IP address is not allocated to the project or does n
ot belong to the specified scope.
I'm following their docs really closely: - https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address
If it had already been claimed in their automatic IP generation by another instance, I would think the error message would be different than this. I also used another gcloud command to look at all my IP reservations and confirm that it is not active on the old project.
Solution 1:[1]
You can only select an IP address that has already been reserved and assigned to your project. You cannot just select any IP address. You will need to reserve a new IP address and update the DNS Resource Records on your DNS servers.
Solution 2:[2]
With your gcloud command, make sure to specify --subnet
, i.e.:
gcloud --project=project-id compute addresses create \
"address-name" \
--region=us-central1 \
--subnet=default \
--addresses=X.X.X.X
You can then specify any X.X.X.X
that fits in the default subnet.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | John Hanley |
Solution 2 | Gillespie |