-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
205 lines (186 loc) · 5.31 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
terraform {
backend "remote" {
hostname = "app.terraform.io"
organization = "mel-ciscolabs-com"
workspaces {
name = "dev-cpoc-coolsox-iks-1"
}
}
required_providers {
helm = {
source = "hashicorp/helm"
}
kubernetes = {
source = "hashicorp/kubernetes"
}
# thousandeyes = {
# source = "william20111/thousandeyes"
# }
thousandeyes = {
source = "thousandeyes/thousandeyes"
version = "1.0.0-alpha.4"
}
}
}
### Remote State - Import Kube Config ###
data "terraform_remote_state" "iks-1" {
backend = "remote"
config = {
organization = "mel-ciscolabs-com"
workspaces = {
name = "iks-cpoc-syd-demo-1"
}
}
}
### Decode Kube Config ###
# Assumes kube_config is passed as b64 encoded
locals {
kube_config = yamldecode(base64decode(data.terraform_remote_state.iks-1.outputs.kube_config))
}
### Providers ###
provider "kubernetes" {
# alias = "iks-k8s"
host = local.kube_config.clusters[0].cluster.server
cluster_ca_certificate = base64decode(local.kube_config.clusters[0].cluster.certificate-authority-data)
client_certificate = base64decode(local.kube_config.users[0].user.client-certificate-data)
client_key = base64decode(local.kube_config.users[0].user.client-key-data)
}
provider "helm" {
kubernetes {
host = local.kube_config.clusters[0].cluster.server
cluster_ca_certificate = base64decode(local.kube_config.clusters[0].cluster.certificate-authority-data)
client_certificate = base64decode(local.kube_config.users[0].user.client-certificate-data)
client_key = base64decode(local.kube_config.users[0].user.client-key-data)
}
}
provider "thousandeyes" {
token = var.te_token # Passed from Workspace Variable
}
### Deploy application via Helm through custom module ###
module "coolsox" {
source = "github.com/cisco-apjc-cloud-se/terraform-helm-coolsox"
smm_enabled = true
panoptica_enabled = true
appd = {
application = {
name = "coolsox-rw"
}
account = {
host = format("%s.saas.appdynamics.com", var.appd_account_name)
name = var.appd_account_name # Passed from Workspace Variable
key = var.appd_account_key # Passed from Workspace Variable
otel_api_key = var.appd_otel_api_key # Passed from Workspace Variable
username = var.appd_account_username # Passed from Workspace Variable
password = var.appd_account_password # Passed from Workspace Variable
}
db_agent = {
enabled = true
name = "coolsox-dbagent"
databases = {
mongodb = {
name = "mongodb"
user = "appdagent"
password = var.appd_account_password
}
}
}
}
helm = {
namespace = "coolsox"
release_name = "coolsox"
repository = "https://github.com/cisco-apjc-cloud-se/app-fso-coolsox/raw/main/application/helm/"
chart = "coolsox"
version = "0.2.3" # In Helm Chart!
wait = false
timeout = 900
}
settings = {
kubernetes = {
repository = "public.ecr.aws/j8r8c0y6/coolsox"
image_pull_policy = "Always"
read_only_root_filesystem = false # breaks AppD Java Agents?
}
carts = {
version = "1.0.0"
replicas = 1
}
catalogue_db = {
version = "1.0.0"
}
catalogue = {
version = "1.0.0"
replicas = 1
appd_tiername = "catalogue"
}
frontend = {
version = "1.0.0"
replicas = 1
appd_browser_rum_enabled = false
ingress = {
enabled = true
url = "fso-demo-app.cisco.com"
}
loadbalancer = {
enabled = false
}
}
orders = {
version = "1.0.0"
replicas = 1
}
payment = {
version = "1.0.0"
replicas = 1
appd_tiername = "payment"
}
queue = {
version = "1.0.0"
}
shipping = {
version = "1.0.0"
replicas = 1
}
user_db = {
version = "1.0.0"
}
user = {
version = "1.0.0"
replicas = 1
appd_tiername = "user"
}
load_test = {
enabled = true
version = "1.0.0"
replicas = 2
}
}
}
### Add Monitoring from ThousandEyes to Public URL ###
module "thousandeyes_tests" {
### NOTE: Requires any Cloud Agents to have access to api.thousandeyes.com ###
source = "github.com/cisco-apjc-cloud-se/terraform-thousandeyes-tests"
http_tests = {
frontend = {
name = "cpoc-coolsox-frontend"
url = "http://fso-demo-app.cisco.com"
alerts_enabled = true
enabled = true
description = "HTTP server test built by Terraform"
bgp_measurements = true
network_measurements = true
mtu_measurements = true
agents = [
"Auckland, New Zealand",
"Brisbane, Australia",
"Melbourne, Australia",
"Melbourne, Australia (Azure australiasoutheast)",
"Perth, Australia",
"Sydney, Australia",
"Wellington, New Zealand"
]
}
}
}
output "test" {
value = module.thousandeyes_tests.test
}