Creating and configuring a GCE instance

After creating the start up script, follow these steps:

  1. With the start up script ready, we can create an instance using the gcloud command:
$ gcloud compute instances create mysite-instance \
--image-family=debian-8 \
--image-project=debian-cloud \
--machine-type=g1-small \
--scopes userinfo-email,cloud-platform \
--metadata-from-file startup-script=./startup-script.sh \
--zone us-east1-c \
--tags mysite-server 
  1. You can check the progress of the instance creation using the following command:
$ gcloud compute instances get-serial-port-output \mysite-instance --zone us-east1-c
  1. Create a firewall rule to allow access to port 3000 to the instance:
$ gcloud compute firewall-rules create default-allow-http-3000 ...

Get Google Cloud Platform Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.