Google Certified Associate Cloud Engineer 2020

Sign Up Free or Log In to participate!

what is the line trying to do in the start up script? worker_log_bucket=$(curl -H “Metadata-Flavor: Google” “${log_bucket_metadata_url}”). Any help please

what is the line trying to do in the start up script? worker_log_bucket=$(curl -H "Metadata-Flavor: Google" "${log_bucket_metadata_url}"). I tried to manually type this command in the ssh session and it did not work

Ionut Dimache

following. Here it seems to break also for me. Followed the stackdriver logs, even tried manually either from the new vm or directly from the cloud shell terminal (i was thinking that maybe there is access rights issue).

Matthew Toczek

The curl command curls the Metadata endpoint ("") on the host and requests the URI of the bucket that you set up. If you read the script, there is a comment on line 42 that tells you to set the attribute to your bucket name. The endpoint allows you to pass in a retrieve variables from within your VM.

1 Answers

I think I understood. The way the script is written, it enforces you to write the bucket as metadata (also mentioned in the course chapter).

1. log_bucket_metadata_name=lab-logs-bucket 

    –> name of the metadata key which you setup during vm creation

2. log_bucket_metadata_url="${log_bucket_metadata_name}"

    –> this is the URL which returns the VALUE of the attribute with the KEY mentioned above

3. worker_log_bucket=$(curl -H "Metadata-Flavor: Google" "${log_bucket_metadata_url}")

    –> as mentioned in previous chapter this data is available for some extra security reasons with that header. Basically it returns into worker_log_bucket variable the VALUE of the KEY (which should be the name of the bucket.

In my case it didnt work initially because out of lasiness but also curiosity to see what happens i hardcoded into the script the name of my bucket and not into the attributes. I was too lazy to check the other things in the script also so I missed some stuff.


Hi Ionut,


So you are suggesting that we need to add these parameters in the metadata field of the vm instance creation. I am a bit confused as I added it and still not able to see the bucket


It takes a bit of time so you have to be patient I suppose. Like Ionot said, the curl command is to get programmatically access to the bucket name from the meta data. Once way to test this would be to SSH into the VM & run the curl command.

Sign In
Welcome Back!

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

Get Started
Who’s going to be learning?