-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_drains.tf
42 lines (34 loc) · 1.4 KB
/
log_drains.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
# Log drains
# How it works :https://doc.scalingo.com/platform/app/log-drain
# API Docs : https://developers.scalingo.com/log_drains
# Log drains for applications
resource "scalingo_log_drain" "app" {
for_each = { for log_drain in var.log_drains : log_drain.type => log_drain }
app = scalingo_app.app.id
type = each.value.type
# Log drain parameters are different depending on the type
url = sensitive(each.value.url)
drain_region = each.value.drain_region
host = each.value.host
port = each.value.port
token = sensitive(each.value.token)
}
# Log drains for addons
resource "scalingo_log_drain" "addons" {
# Create a map of log_drain for each addon and log_drain combination :
# e.g. { "redis-elk" = { addon_id = "xxxx", type = "elk", url = "https://elk.example.com/xxxx" } }
for_each = { for log_drain in setproduct(var.log_drains, values(scalingo_addon.addons)) :
"${log_drain[1].provider_id}-${log_drain[0].type}"
=> merge(log_drain[0], { addon_id = log_drain[1].id })
}
# Associate the log drain to app AND addon
app = scalingo_app.app.id
addon = each.value.addon_id
type = each.value.type
# Log drain parameters are different depending on the type
url = sensitive(each.value.url)
drain_region = each.value.drain_region
host = each.value.host
port = each.value.port
token = sensitive(each.value.token)
}