We will use Google Cloud Platform Deployment Manager in this tutorial. Deployment manager uses a system of templates to consistently deploy GCP resources. You create files to instruct Deployment Manager.
Create a Project or use an existing one, Deployment Manager requires a GCP Console project to use.
First we will login to GCP account. Then open Google Cloud Shell (gcloud).
Create a folder for the Deployment Manager files.
|$ mkdir myfirstdeployman
$ cd myfirstdeployman
Creating a Configuration
We will create the YAML file and add the basic configuration for Virtual Machine instance. We will use nano as for the text editor. Note: replace [MY_PROJECT] with the project ID from GCP console.
|$ nano my-vm.yaml
– name: my-vm
– deviceName: boot
– network: https://www.googleapis.com/compute/v1/projects/[MY_PROJECT]/global/networks/default
– name: External NAT
This configuration file will be used to create a virtual machine called “my-vm”, the machine type will be “f1-micro”, zone will be “us-centeral1-f” and the image will be debian-9.
Create the deployment using the below command
|$ gcloud deployment-manager deployments create my-first-vm-deployment –config my-vm.yaml|
It could take few minutes to complete, you should see an output like below
NAME TYPE STATE ERRORS INTENT
my-vm compute.v1.instance COMPLETED 
Now you can go and check your new VM should be created and listed on Computer Engine>VM Instances.
If you encountered an error during the creating of the deployment manager, or you want to undo/delete use the below command
|$ gcloud deployment-manager deployments delete my-first-vm-deployment|
This will delete any resources in the your deployment file.