-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
231 lines (190 loc) · 6.98 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
data "google_client_config" "example" {}
# locals {
# k8_provider_config = {
# host = "https://${google_container_cluster.primary.endpoint}"
# token = data.google_client_config.example.access_token
# cluster_ca_certificate = base64decode(google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
# ignore_annotations = [
# "^autopilot\\.gke\\.io\\/.*",
# "^cloud\\.google\\.com\\/.*"
# ]
# }
# }
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "5.41.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.32.0"
}
kubectl = {
source = "alekc/kubectl"
version = "2.0.4"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "4.39.0"
}
helm = {
source = "hashicorp/helm"
version = "2.15.0"
}
newrelic = {
source = "newrelic/newrelic"
version = "3.45.0"
}
graphql = {
source = "sullivtr/graphql"
version = "2.5.5"
}
}
}
# provider "kubernetes" {
# host = local.k8_provider_config.host
# token = local.k8_provider_config.token
# cluster_ca_certificate = local.k8_provider_config.cluster_ca_certificate
# ignore_annotations = local.k8_provider_config.ignore_annotations
# }
# provider "kubectl" {
# host = local.k8_provider_config.host
# token = local.k8_provider_config.token
# cluster_ca_certificate = local.k8_provider_config.cluster_ca_certificate
# }
provider "google" {
credentials = file(var.sa_credentials_file_path)
project = var.project_id
region = var.project_region
}
provider "kubernetes" {
host = module.clusters.k8_provider_config.host
token = data.google_client_config.example.access_token
cluster_ca_certificate = module.clusters.k8_provider_config.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
provider "kubectl" {
host = module.clusters.k8_provider_config.host
token = data.google_client_config.example.access_token
cluster_ca_certificate = module.clusters.k8_provider_config.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
provider "helm" {
kubernetes {
host = module.clusters.k8_provider_config.host
token = data.google_client_config.example.access_token
cluster_ca_certificate = module.clusters.k8_provider_config.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
}
provider "cloudflare" {
email = var.cloudflare_email
api_key = var.cloudflare_api_key
}
provider "newrelic" {
account_id = var.nr_account_id
api_key = var.nr_api_key
region = "US"
}
provider "graphql" {
url = "https://api.newrelic.com/graphql"
headers = {
"Content-Type" = "application/json"
"API-Key" = var.nr_api_key
}
}
# module "providers" {
# source = "./providers"
# sa_credentials_file_path = var.sa_credentials_file_path
# project_id = var.project_id
# project_region = var.project_region
# cloudflare_email = var.cloudflare_email
# cloudflare_api_key = var.cloudflare_api_key
# nr_account_id = var.nr_account_id
# nr_api_key = var.nr_api_key
# }
module "apis" {
source = "./apis"
project_id = var.project_id
# depends_on = [module.providers]
}
module "iam" {
source = "./iam"
project_id = var.project_id
depends_on = [module.apis]
}
module "networks" {
source = "./networks"
ingress_hosts = var.ingress_hosts
name_prefix_kebab = var.name_prefix_kebab
firewall_allow_ssh = var.firewall_allow_ssh
firewall_allow_http = var.firewall_allow_http
firewall_allow_https = var.firewall_allow_https
depends_on = [module.iam]
}
module "clusters" {
source = "./clusters"
name_prefix_kebab = var.name_prefix_kebab
firewall_allow_http = var.firewall_allow_http
firewall_allow_https = var.firewall_allow_https
project_region = var.project_region
example_network_id = module.networks.example_network_id
google_compute_global_address_ingress_name = module.networks.google_compute_global_address_ingress_name
# google_container_cluster_primary_name = google_container_cluster.primary.name
# google_container_cluster_primary_location = google_container_cluster.primary.location
depends_on = [module.networks]
}
module "deployments" {
source = "./deployments"
name_prefix_kebab = var.name_prefix_kebab
cloudflare_api_key = var.cloudflare_api_key
depends_on = [module.clusters]
}
module "certmanager_a" {
source = "./certmanager"
ingress_hosts = var.ingress_hosts
cloudflare_api_key = var.cloudflare_api_key
cluster_issuer_email = var.cluster_issuer_email
cloudflare_email = var.cloudflare_email
cluster_issuer_private_key_secret_name = var.cluster_issuer_private_key_secret_name
depends_on = [module.deployments]
}
module "services" {
source = "./services"
name_prefix_kebab = var.name_prefix_kebab
kubernetes_deployment_v1_example_spec = module.deployments.kubernetes_deployment_v1_example_spec
depends_on = [module.deployments, module.certmanager_a]
}
module "ingress" {
source = "./ingress"
name_prefix_kebab = var.name_prefix_kebab
google_compute_global_address_ingress_name = module.networks.google_compute_global_address_ingress_name
kubernetes_deployment_v1_example_spec = module.deployments.kubernetes_deployment_v1_example_spec
cluster_issuer_private_key_secret_name = var.cluster_issuer_private_key_secret_name
kubernetes_service_v1_example = module.services.kubernetes_service_v1_example
cert_manager_cluster_issuer_name = module.certmanager_a.cluster_issuer_name
ingress_hosts = var.ingress_hosts
depends_on = [module.services, module.deployments]
}
module "newrelic" {
source = "./newrelic"
project_id = var.project_id
name_prefix_kebab = var.name_prefix_kebab
nr_global_license_key = var.nr_global_license_key
nr_account_id = var.nr_account_id
nr_newrelic_pixie_api_key = var.nr_newrelic_pixie_api_key
nr_sa = var.nr_sa
nr_pixie_chart_deploy_key = var.nr_pixie_chart_deploy_key
google_container_cluster_primary_name = module.clusters.google_container_cluster_primary_name
depends_on = [module.ingress]
}