Metadata startup scirpt

Skip to first unread message

Andreas Potamitis

Nov 29, 2021, 12:03:45 PM11/29/21
to gce-discussion
Hello community.
I am trying to deploy a google compute engine using terraform. The instance is created successfully but I am having issues deploying metadata startup scripts. 
I checked permissions, syntax based on documentation and using windows-startup-script-ps1 = "basic powershell commands" it seems that the commands are not executed at all.
Checked the logs in port 1 and during checks, it does not even identify that there are metadata to be executed during the instance deployment.
Also, the metadata script is visible on the instance information panel, on the bottom.
Any help appreciated.
Thank you.

Prakash Shanmugam

Dec 1, 2021, 10:56:35 AM12/1/21
to gce-discussion
Hi Andreas Potamitis

As per google documentation, "windows-startup-script-ps1" will be executed after each time of initial boot. If you want the scripts to be executed at initial boot, you need to change the startup script key as "sysprep-specialize-script-ps1". 

You can refer the complete documentation about the order of startup script execution for windows at

Let me know if this helps to get resolved your issue.  

Digil (Google Cloud Platform Support)

Dec 1, 2021, 4:18:06 PM12/1/21
to gce-discussion
Hello Andreas,

As explained by the other community support person, I believe you have to use the 'sysprep_specialize-script-ps1' as the metadata key for the startup script to get it executed during the time-of initial booting of the GCE VM.

Before testing it by using your 'Terraform environment', I would also recommend you to test the scenario by passing the startup script directly (OR from a local file OR from a Cloud Storage) to see if it is executing properly. If it is providing the expected result, then you might need to get in touch with the Terraform's support channel for an additional review of your code. If it is not providing an expected result, then I would strongly recommend you to report it as a defect(bug) using the Google Cloud Platform's issue-tracker report channel. While opening the issue-tracker report, try to include as many details, such as reproduction steps, documents you were following, etc.

Yaqub Omofoyewa

Dec 6, 2021, 5:12:10 AM12/6/21
to Digil (Google Cloud Platform Support), gce-discussion
Hello Andreas,
 I am trying to get something right here about what you mean by "but I am having issues deploying metadata startup scripts." Attaching a metadata script is an automated startup script that you do not have to interfere with whenever you are using Terraform on GCP. 

It will be attached to your resource "google_cloud_instance" code. In addition, it is expected to be like this  metadata_startup_script = "echo hi > /test.txt"
More informations about Terraform metadata startup script for compute engine can be found here:

Best regards


© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group ( to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
You received this message because you are subscribed to the Google Groups "gce-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages