How to write a metadata_startup_script to install and run apache server in GCP through terraform

Able to spin up a VM through terraform but unable to run the metadata_startup_script successfully. The logs show these errors:

ERROR oslogin.go:126 Error reloading service: ssh.service is not active, cannot reload…
/bin/bash: /tmp/metadata-scripts511320383/startup-script: /bin/bash^M: bad interpreter: No such file or directory