when I want to use metadata_startup_script in template if I use commands in one line it works fine but in pass one line or even if I want to use some html it does not work fine and I face error (multiple lines in terraform and use new line and if I want to refer it to local bash script with some thing like metadata_startup_script = "${file("startup.sh")}" it work but when instance come up ,When I ssh to it my appache does not install in machine so my startup script doesnt work but I have the in the template!
what is the issue for that ,is anybody have ay idea about that?
Google Cloud Terraform – Using metadata_startup_script in Google Cloud Template with Terraform
google-cloud-platformterraform
Best Answer
As you mentioned you can see the script in template, I would recommend you to check in the console and check if your script is visible, if yes check the serial console to check why your script is not running. It might due to typo or due to missing the confirmation/consent.
To reproduce your issue I am following the documentation now set my
main.tf
as below:In that file i set my startup script as below:
After creating the vm i can see the apache is running in my instance.