forked from jruels/tf-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
36 lines (32 loc) · 839 Bytes
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
resource "google_compute_instance" "demo" {
count = var.number_of_demo_instances
name = "web-instance-${count.index}"
machine_type = "e2-small"
zone = "us-west1-a"
metadata = {
ssh-keys = "ubuntu:${file("/bitnami/jenkins/home/tf-key.pub")}"
}
# boot disk specifications
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1804-lts"
}
}
# networks to attach to the VM
network_interface {
network = "default"
access_config {} // use ephemeral public IP
}
}
resource "google_compute_firewall" "demo" {
name = "allow-gce-tcp-80"
network = "default"
allow {
protocol = "tcp"
ports = ["80"]
}
source_ranges = ["0.0.0.0/0"]
}
output "web_vm_ip" {
value = [google_compute_instance.demo.*.network_interface.0.access_config.0.nat_ip]
}