Skip to content

Instantly share code, notes, and snippets.

@iht
Last active October 15, 2022 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iht/6219b227424ada477462c7b9d9d93c57 to your computer and use it in GitHub Desktop.
Save iht/6219b227424ada477462c7b9d9d93c57 to your computer and use it in GitHub Desktop.
Commands to create a Google Cloud VM and disk for Hop web to run Dataflow jobs
# Google Cloud zone to use for the resources
ZONE=europe-west1-b
# If not running in Cloud Shell, set the variable GOOGLE_CLOUD_PROJECT to your project id
# GOOGLE_CLOUD_PROJECT=<PROJECT ID>
# Get service account id
SERVICE_ACCOUNT=$(gcloud iam service-accounts list | grep "compute@developer.gserviceaccount.com" | cut -d " " -f 2)
# Add permission to run Dataflow jobs
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT --member="serviceAccount:$SERVICE_ACCOUNT" --role="roles/dataflow.admin"
# Create disk to store persistent files
gcloud compute disks create my-hop-disk --type=pd-balanced --size=10GB --zone=$ZONE
# Create VM with Hop web container
gcloud compute instances create-with-container my-hop-vm \
--zone=$ZONE \
--network-interface=subnet=default,no-address \
--scopes=https://www.googleapis.com/auth/cloud-platform \
--tags=http-server,https-server,ssh \
--container-image=apache/hop-web:2.0.1 \
--container-restart-policy=on-failure \
--container-mount-disk=mode=rw,mount-path=/root,name=my-hop-disk,partition=0 \
--disk=boot=no,device-name=my-hop-disk,mode=rw,name=my-hop-disk
echo Now start a tunnel running the command:
echo gcloud compute start-iap-tunnel my-hop-vm 8080 --local-host-port=localhost:8080 --zone=$ZONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment