google-cloud-platformgoogle-deployment-manager

Startup scripts in GCP deployment manager


I'm deploying a VM instance using GCP deployment manager. There are some initialization actions which should be executed over deployment process. I have imported a startup script and added the metadata-from-file property following this example: https://github.com/GoogleCloudPlatform/deploymentmanager-samples/blob/master/examples/v2/metadata_from_file/jinja/config.yaml

But I don't see those actions getting executed. Any other way to have such scripts included in the deployment plan?


Solution

  • The startup script file execute a file present in the vm at startup. If you deploy your VM with deployment manager, your VM is new. Thus the file has to already exists in the boot image. Are you using a custom image?

    If not, I recommend you to use startup script url and specify the startup file stored in Google storage. Be sure that the compute engine has enough right to read the file. More detail on compute engine startup script here: https://cloud.google.com/compute/docs/startupscript