-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
66 lines (54 loc) · 1.74 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
resource "google_service_account" "default" {
account_id = "service-account-id"
display_name = "Service Account"
}
resource "google_project_iam_binding" "service_account_role1" {
project = var.project_name
role = "roles/monitoring.metricWriter"
members = [
//the service account email I created in the previous step
"serviceAccount:${google_service_account.default.email}"
]
}
resource "google_project_iam_binding" "service_account_role2" {
project = var.project_name
role = "roles/logging.logWriter"
members = [
//the service account email I created in the previous step
"serviceAccount:${google_service_account.default.email}"
]
}
resource "google_project_iam_binding" "service_account_role3" {
project = var.project_name
role = "roles/stackdriver.resourceMetadata.writer"
members = [
//the service account email I created in the previous step
"serviceAccount:${google_service_account.default.email}"
]
}
resource "google_container_cluster" "primary" {
name = "my-gke-cluster"
location = var.region
remove_default_node_pool = true
initial_node_count = 1
master_auth {
client_certificate_config {
issue_client_certificate = true
}
}
}
resource "google_container_node_pool" "primary_preemptible_nodes" {
name = "my-node-pool"
location = var.region
cluster = google_container_cluster.primary.name
node_count = 1
node_config {
preemptible = true
machine_type = "e2-medium"
# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
service_account = google_service_account.default.email
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
}
}