GoogleCloudPlatform / gcping

The source for the CLI and web app at gcping.com

Home Page:https://gcping.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform fails if /etc/hosts doesn't contain IPv4 addrs

crwilcox opened this issue · comments

Currently, terraform can fail due to a misconfig of addrs. It would be better if this could be added to our terraform.

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6=1 > /dev/null
export APIS="googleapis.com www.googleapis.com storage.googleapis.com iam.googleapis.com container.googleapis.com cloudresourcemanager.googleapis.com run.googleapis.com iam.googleapis.com asia-east2-run.googleapis.com southamerica-east1.googleapis.com asia-south1-run.googleapis.com europe-west2-run.googleapis.com australia-southeast2-run.googleapis.com europe-north1-run.googleapis.com europe-west3-run.googleapis.com southamerica-east1-run.googleapis.com asia-southeast1-run.googleapis.com asia-northeast1-run.googleapis.com us-west3-run.googleapis.com us-central1-run.googleapis.com asia-northest2-run.googleapis.com us-east4-run.googleapis.com australia-southeast1-run.googleapis.com us-east4-run.googleapis.com europe-west3-run.googleapis.com"
for name in $APIS
do
  ipv4=$(getent ahostsv4 "$name" | head -n 1 | awk '{ print $1 }')
  grep -q "$name" /etc/hosts || ([ -n "$ipv4" ] && sudo sh -c "echo '$ipv4 $name' >> /etc/hosts")
done

Repro:

terraform plan \
    --var="image=gcr.io/gcping-devrel/ping-b5e9c300f5e9cdafa118e623a88e6b97@sha256:14ae944d9449281f08e2dfb4abac70ec43429f7fcb3e47dba3ad750a7842b53a" \
    --var='domain=gcping.com' \
    --var='project=gcping-devrel'

Related to hashicorp/terraform-provider-google#6782.

I suspect this is something to do with Cloud Shell and the Go DNS resolver.

This isn't a gcping issue. It's something to do with the Cloud Shell env.