mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-14 23:17:15 +00:00
f7bdcde1c4
Brings up four projects: - one to host the VPC - two to use the VPC - one which is outside the VPC This is based on the diagram in https://cloud.google.com/vpc/docs/shared-vpc and uses the names there where possible for clarity. On one of the machines, a page is generated demonstrating that the networking is working the way you'd expect. That machine's public IP is output by `terraform apply`.
47 lines
1014 B
Bash
47 lines
1014 B
Bash
sudo apt-get update
|
|
sudo apt-get install apache2 -y
|
|
sudo a2ensite default-ssl
|
|
sudo a2enmod ssl
|
|
sudo service apache2 restart
|
|
sudo cat > /var/www/html/index.html << EOF
|
|
<!doctype html><html><body>
|
|
<h1>Network Status for Shared VPC Terraform/Google Cloud Example</h1>
|
|
<h2>VM 1</h2>
|
|
<h3>Internal IP: $VM1_INT_IP</h3>
|
|
<pre>
|
|
$ ping -c 4 -W 1 $VM1_INT_IP
|
|
$(ping -c 4 -W 1 $VM1_INT_IP)
|
|
|
|
$ curl $VM1_INT_IP
|
|
$(curl $VM1_INT_IP)
|
|
</pre>
|
|
<h3>External IP: $VM1_EXT_IP</h3>
|
|
<pre>
|
|
$ ping -c 4 -W 1 $VM1_EXT_IP
|
|
$(ping -c 4 -W 1 $VM1_EXT_IP)
|
|
|
|
$ curl $VM1_EXT_IP
|
|
$(curl $VM1_EXT_IP)
|
|
</pre>
|
|
<h2>Standalone VM</h2>
|
|
<h3>Internal IP: $ST_VM_INT_IP</h3>
|
|
$(if [ $ST_VM_INT_IP = $VM1_INT_IP ]; then echo "<h4>Same internal IP as VM1</h4>"; fi)
|
|
<pre>
|
|
$ ping -c 4 -W 1 $ST_VM_INT_IP
|
|
$(ping -c 4 -W 1 $ST_VM_INT_IP)
|
|
|
|
$ curl $ST_VM_INT_IP
|
|
$(curl $ST_VM_INT_IP)
|
|
</pre>
|
|
<h3>External IP: $ST_VM_EXT_IP</h3>
|
|
<pre>
|
|
$ ping -c 4 -W 1 $ST_VM_EXT_IP
|
|
$(ping -c 4 -W 1 $ST_VM_EXT_IP)
|
|
|
|
$ curl $ST_VM_EXT_IP
|
|
$(curl $ST_VM_EXT_IP)
|
|
</pre>
|
|
</body></html>
|
|
|
|
EOF
|