I can't create instance in GCP with gcloud console:
1. If script local, everything it OK:
gcloud compute instances create app \
--boot-disk-size=10GB \
--image-family ubuntu-1604-lts \
--image-project=ubuntu-os-cloud \
--machine-type=g1-small \
--restart-on-failure \
--metadata-from-file startup-script=install.sh
2. If I user startup-script-url with gsutil URI, like this:
gcloud compute instances create appĀ \
--boot-disk-size=10GB \
--image-family ubuntu-1604-ltsm \
--image-project=ubuntu-os-cloud \
--machine-type=g1-small \
--restart-on-failure \
--metadata-from-file startup-script-url=gs://mbps54/install.sh
Then I received:
ERROR: (gcloud.compute.instances.create) Unable to read file [gs://mbps54/install.sh]. [Errno 2] No such file or directory: 'gs://mbps54/install.sh' gsutil URI is gs://mbps54/install.sh
3. If I user startup-script-url with Public URL,like this:
gcloud compute instances create reddit-appĀ \
--boot-disk-size=10GB \
--image-family ubuntu-1604-ltsm \
--image-project=ubuntu-os-cloud \
--machine-type=g1-small \
--restart-on-failure \
--metadata-from-file startup-script-url=https://storage.googleapis.com/mbps54/install.sh
I received:**
ERROR: (gcloud.compute.instances.create) Unable to read file [https://storage.googleapis.com/mbps54/install.sh]: [Errno 2] No such file or directory: 'https://storage.googleapis.com/mbps54/install.sh'
4. Here are my bucket settings
And I can open https://storage.googleapis.com/mbps54/install.sh from any other PC. Additionally, to make sure access is public, I did this:
gsutil defacl set public-read gs://mbps54
gsutil -m acl set -R -a public-read gs://mbps54
5. This bucket url is Public and opens from any PC https://storage.googleapis.com/mbps54/install.sh opens from other PC.
Could somebody help, what is wrong with my configuration and script?
You're using the
--metadata-from-file
flag, which expects you to supply a local file. If you want to specify a startup script from a URL instead, you want the--metadata
flag, i.e.:This is mentioned at https://cloud.google.com/compute/docs/startupscript#startupscriptrunninginstances under the
gcloud
tab.