Created
May 24, 2022 00:37
-
-
Save samos123/849fa8c911ab70a4523219b990473580 to your computer and use it in GitHub Desktop.
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 | |
set -x | |
REGION=$1 | |
ZONE=$REGION-a | |
gcloud compute routers create router-$REGION --network=default --region=$REGION | |
gcloud compute routers nats create nat-$REGION \ | |
--router=router-$REGION \ | |
--region $REGION \ | |
--auto-allocate-nat-external-ips \ | |
--nat-all-subnet-ip-ranges \ | |
--enable-logging | |
gcloud compute instances create latency-$REGION --boot-disk-size 100G --boot-disk-type pd-ssd --machine-type n2-standard-2 --zone $ZONE --network default --no-address --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring | |
while ! gcloud compute ssh latency-$REGION --zone $ZONE --command "echo SSH to $VM_NAME succeeded" --tunnel-through-iap | |
do | |
echo "Trying to SSH into failed. Sleeping for 5 seconds. zzzZZzzZZ" | |
sleep 5 | |
done | |
gcloud compute ssh latency-$REGION --zone $ZONE --command "sudo apt -qq update -y && sudo apt -qq install traceroute -y; sudo traceroute -n -I 8.8.8.8" --tunnel-through-iap | |
gcloud compute ssh latency-$REGION --zone $ZONE --command "ping -c3 8.8.8.8" --tunnel-through-iap | |
gcloud compute instances delete latency-$REGION --zone $ZONE --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment