Last active
May 2, 2020 13:47
-
-
Save TiagoGouvea/6b64d8b91f7ff819815b2f6a658d2c4e to your computer and use it in GitHub Desktop.
Sample script to create a Google Compute Engine VM instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo -e "\nCreate remote instance" | |
echo -e "\n# 1/2 - Loading and setting options..." | |
## Show commands (if you want to check, uncomment it) | |
#set -x | |
## Stop on errors | |
set -e | |
## Include config | |
source config.sh | |
## Set GCP compute zone | |
gcloud config set project ${PROJECT} | |
gcloud config set compute/zone ${ZONE} | |
## Create instance | |
echo -e "\n# 1/2 - Creating Compute Instance..." | |
gcloud compute instances create ${INSTANCE_NAME} \ | |
--image-family ${IMAGE_FAMILY} \ | |
--image-project ${IMAGE_PROJECT} \ | |
--machine-type ${MACHINE_TYPE} \ | |
--zone ${ZONE} \ | |
--tags ${TAGS} \ | |
--${DELETION_PROTECTION} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment