I am using the gcloud CLI to try to complete the lab. I don’t see the logs on my bucket.
I put all my commands here for reference : https://github.com/ibnjay/gcloud-practice/blob/master/acloud-guru-challenge.sh
Final command is this :
gcloud compute instances create example-instance2
–zone us-central1-a –machine-type=f1-micro –scopes storage-rw,default
I am passing the startup-script as a storage file.
I’m not sure you can use google storage in "startup-script-url" as documentation states:
"startup-script-url Same as startup-script except that the script contents are pulled from a publicly-accessible location on the web."
Instead you can directly provide a startup script via "metadata-from-file" parameter like this:
I tried this too. Still don’t see the logs on bucket. Your modification works and so did the original commands. I am able to see scripts logs in stackdriver for both. logs such as :
startup-script: INFO startup-script-url: + apt-get -yq install stress
Oh I think I found the issue on stack driver I see : computeMetadata/v1/instance/attributes/lab-logs-bucket was not found on this server
Metadata property had wrong name. Final command was : gcloud compute instances create example-instance3 –zone us-central1-a –machine-type=f1-micro –scopes storage-rw,default –metadata lab-logs-bucket=gs://jay-startup –metadata-from-file=startup-script=gcloudboot.sh
I know this is resolved, but just a quick comment – startup-script-url can be used with Cloud Storage. The URL just needs to be accessible to the machine (bucket must have correct permissions) and doesn’t necessarily have to be public. Food for thought, in environments, where outbound access is restricted (no Internet access/no external IPs) cloud storage is probably the better place to store any startup scripts. Where they’re stored depends on each company’s GCP architecture, but doing so helps you not eat your combined metadata limits of 512KB as well.