We are using the server I created on Google Cloud Platform to create and manage other servers. But when trying to create a new server from the Linux command line using the GCloud compute instance creation function, we receive The following error:
marco@ans-mgmt-01:~/gcloud$ ./create_gcloud_instance.sh app-tst-04 tst,backend-server,bootstrap home-tst 10.20.22.104 ERROR: (gcloud.compute.instances.create) Could not fetch resource: - The resource 'projects/REMOVED_OUR_PROJECTID/global/images/family/debian-8' was not found
Our script looks like this:
#!/bin/bash if [ "$#" -ne 4 ]; then echo "Usage: create_gcloud_instance " exit 1 fi set -e INSTANCE_NAME=$1 TAGS=$2 SERVER_SUBNET=$3 SERVER_IP=$4 gcloud compute --project "REMOVED OUR PROJECT ID" instances create "$INSTANCE_NAME" \ --zone "europe-west1-c" \ --machine-type "f1-micro" \ --network "cloudnet" \ --subnet "$SERVER_SUBNET" \ --no-address \ --private-network-ip="$SERVER_IP" \ --maintenance-policy "MIGRATE" \ --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/ auth/monitoring.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www. googleapis.com/auth/trace.append" \ --service-account "default" \ --tags "$TAGS" \ --image-family "debian-8" \ --boot-disk-size "10" \ --boot-disk-type "pd-ssd" \ --boot-disk-device-name "bootdisk-$INSTANCE_NAME" \ ./clean_known_hosts.sh $INSTANCE_NAME
On the Google Cloud Console (console.cloud.google.com), I enabled the cloud api access scope for the ans-mgmt-01 server and tried to create the server from there. There was no problem.
1> Stephen Wein..:
The problem is that gcloud is looking for the image series in the project, not the debian-cloud project where it actually exists.
This can be solved by simply using --image-project debian-cloud
.
Instead of looking for projects/{yourID}/global/images/family/debian-8
, this method looks for projects/debian-cloud/global/images/family/debian -8
.