forked from vmware-archive/terraforming-gcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ops_manager.tf
122 lines (99 loc) · 3.26 KB
/
ops_manager.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Allow HTTP/S access to Ops Manager from the outside world
resource "google_compute_firewall" "ops-manager-external" {
name = "${var.env_name}-ops-manager-external"
network = "${google_compute_network.pcf-network.name}"
target_tags = ["${var.env_name}-ops-manager-external"]
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22", "80", "443"]
}
}
resource "google_compute_image" "ops-manager-image" {
name = "${var.env_name}-ops-manager-image"
create_timeout = 20
raw_disk {
source = "${var.opsman_image_url}"
}
}
resource "google_compute_image" "optional-ops-manager-image" {
name = "${var.env_name}-optional-ops-manager-image"
count = "${min(length(split("", var.optional_opsman_image_url)),1)}"
create_timeout = 20
raw_disk {
source = "${var.optional_opsman_image_url}"
}
}
resource "google_compute_address" "ops-manager-ip" {
name = "${var.env_name}-ops-manager-ip"
}
resource "google_compute_instance" "ops-manager" {
name = "${var.env_name}-ops-manager"
machine_type = "${var.opsman_machine_type}"
zone = "${element(var.zones, 1)}"
create_timeout = 10
tags = ["${var.env_name}-ops-manager-external"]
boot_disk {
initialize_params {
image = "${google_compute_image.ops-manager-image.self_link}"
size = 150
}
}
network_interface {
subnetwork = "${google_compute_subnetwork.management-subnet.name}"
access_config {
nat_ip = "${google_compute_address.ops-manager-ip.address}"
}
}
service_account {
email = "${google_service_account.opsman_service_account.email}"
scopes = ["cloud-platform"]
}
metadata = {
ssh-keys = "${format("ubuntu:%s", tls_private_key.ops-manager.public_key_openssh)}"
block-project-ssh-keys = "TRUE"
}
}
resource "google_compute_address" "optional-ops-manager-ip" {
name = "${var.env_name}-optional-ops-manager-ip"
count = "${min(length(split("", var.optional_opsman_image_url)),1)}"
}
resource "google_compute_instance" "optional-ops-manager" {
name = "${var.env_name}-optional-ops-manager"
machine_type = "${var.opsman_machine_type}"
zone = "${element(var.zones, 1)}"
count = "${min(length(split("", var.optional_opsman_image_url)),1)}"
create_timeout = 10
tags = ["${var.env_name}-ops-manager-external"]
boot_disk {
initialize_params {
image = "${google_compute_image.optional-ops-manager-image.self_link}"
size = 150
}
}
network_interface {
subnetwork = "${google_compute_subnetwork.management-subnet.name}"
access_config {
nat_ip = "${google_compute_address.optional-ops-manager-ip.address}"
}
}
service_account {
email = "${google_service_account.opsman_service_account.email}"
scopes = ["cloud-platform"]
}
metadata = {
ssh-keys = "${format("ubuntu:%s", tls_private_key.ops-manager.public_key_openssh)}"
block-project-ssh-keys = "TRUE"
}
}
resource "google_storage_bucket" "director" {
name = "${var.project}-${var.env_name}-director"
force_destroy = true
count = "${var.opsman_storage_bucket_count}"
}
resource "tls_private_key" "ops-manager" {
algorithm = "RSA"
rsa_bits = "4096"
}