-
Notifications
You must be signed in to change notification settings - Fork 93
/
main.tf
48 lines (38 loc) · 1018 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
37
38
39
40
41
42
43
44
45
46
47
48
# Configure the Google Cloud provider
provider "google" {
project = "terraform-examples-gcloud"
region = "us-east1"
}
# Create a Google Compute Firewall
resource "google_compute_firewall" "instance" {
name = "terraform-example-instance"
network = "default"
source_ranges = ["0.0.0.0/0"]
allow {
protocol = "tcp"
ports = ["8080"]
}
}
# Create a Google Compute instance
resource "google_compute_instance" "example" {
name = "example"
machine_type = "f1-micro"
zone = "us-east1-b"
boot_disk {
initialize_params {
image = "ubuntu-1604-lts"
}
}
network_interface {
network = "default"
access_config {
// Ephemeral IP
}
}
tags = ["terraform-example"]
metadata_startup_script = "echo 'Hello, World' > index.html ; nohup busybox httpd -f -p 8080 &"
}
# Output variable: Public IP address
output "public_ip" {
value = "${google_compute_instance.example.network_interface.0.access_config.0.assigned_nat_ip}"
}