Skip to content

Instantly share code, notes, and snippets.

@vvdaal
Last active May 21, 2021 07:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvdaal/daa206ed33abd3577af774944c350bd5 to your computer and use it in GitHub Desktop.
Save vvdaal/daa206ed33abd3577af774944c350bd5 to your computer and use it in GitHub Desktop.
Bash script for fixing the IPv6 issue with Terraform on Google Cloud Shell
#!/bin/bash
#
#Make root the owner of this file and execute in your .bashrc with sudo ./fix_hosts_google_shell.sh
#Make sure sudo uses passwordless auth
#
if grep -q "googleapis.com" /etc/hosts
then
echo "Googleapis detected in /etc/hosts, skipping bug workaround for connectivity"
exit 1
#Exists so exit script
else
export APIS="googleapis.com www.googleapis.com storage.googleapis.com iam.googleapis.com container.googleapis.com cloudresourcemanager.googleapis.com compute.googleapis.com pubsub.googleapis.com secretmanager.googleapis.com"
for i in $APIS
do
echo "199.36.153.10 $i" >> /etc/hosts
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment