Google Certified Associate Cloud Engineer 2020

Sign Up Free or Log In to participate!

Don’t see logs. Using cli with scope

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 :

Final command is this : 

gcloud compute instances create example-instance2

–zone us-central1-a –machine-type=f1-micro –scopes storage-rw,default

–metadata startup-script-url=gs://jay-startup/,log_bucket_metadata_name=gs://jay-startup

I am passing the startup-script as a storage file.

1 Answers

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:


Dhananjay Tripathi

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

Dhananjay Tripathi

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

Dhananjay Tripathi

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 –

Momin Zaheer

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?