Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google cloud's glcoud compute instance create gives error "The resource projects/{ourID}/global/images/family/debian-8 was not found

We are using a server I created on Google Cloud Platform to create and manage the other servers over there. But when trying to create a new server from the Linux command line with the GCloud compute instances create 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 <instance_name> <tags> <subnet_name> <server_ip>"                                                                                                                                                                                                                
    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 also tried to create a server from there. That's working without problems.

like image 435
Marco Avatar asked Jul 24 '17 11:07

Marco


People also ask

What are some common errors in Google Cloud Platform?

google cloud platform - ERROR: (gcloud.compute.instances.create) Could not fetch resource: - Quota 'GPUS_ALL_REGIONS' exceeded. Limit: 0.0 globally - Stack Overflow ERROR: (gcloud.compute.instances.create) Could not fetch resource: - Quota 'GPUS_ALL_REGIONS' exceeded.

How do I create an instance of a Google Cloud project?

By default, all Google Cloud projects have access to these images and can use them to create instances. Custom images are available only to your Cloud project. You can create a custom image from boot disks and other images. Then, use the custom image to create an instance.

How do I create a boot disk for my Google Cloud instance?

Use operating system images to create boot disks for your instances. You can use one of the following image types: Public images are provided and maintained by Google, open source communities, and third-party vendors. By default, all Google Cloud projects have access to these images and can use them to create instances.

What is the quota limit for GCloud compute instances?

ERROR: (gcloud.compute.instances.create) Could not fetch resource: - Quota 'GPUS_ALL_REGIONS' exceeded. Limit: 0.0 globally. More information about quotas you can find in the documentation.


1 Answers

The problem is that gcloud is looking for the image family in your project and not the debian-cloud project where it really exists.

This can be fixed by simply using --image-project debian-cloud.

This way instead of looking for projects/{yourID}/global/images/family/debian-8, it will look for projects/debian-cloud/global/images/family/debian-8.

like image 117
Stephen Weinberg Avatar answered Nov 04 '22 22:11

Stephen Weinberg