-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
53 lines (42 loc) · 1021 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
49
50
51
52
53
provider "google" {
project = "${var.gcp_project_id}"
credentials = "${file("account.json")}"
version = "2.9.1"
}
provider "null" {
version = "2.1.2"
}
resource "google_compute_network" "vpc_network" {
name = "terraform-network"
auto_create_subnetworks = "true"
}
resource "google_compute_firewall" "ssh-only" {
name = "test-firewall"
network = "${google_compute_network.vpc_network.self_link}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22"]
}
source_ranges = ["0.0.0.0/0"]
}
resource "google_compute_address" "static" {
name = "ipv4-address"
}
resource "google_compute_instance" "vm_instance" {
name = "terraform-instance"
machine_type = "f1-micro"
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
network_interface {
network = "${google_compute_network.vpc_network.self_link}"
access_config {
nat_ip = "${google_compute_address.static.address}"
}
}
}