-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
39 lines (34 loc) · 1.08 KB
/
main.tf
File metadata and controls
39 lines (34 loc) · 1.08 KB
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
locals {
enabled = alltrue([
fileexists(var.input_file_path),
var.client_id != "",
var.client_secret != "",
var.base_url != "",
var.output_file_path != "",
])
input_file_content = local.enabled ? file(var.input_file_path) : ""
template_variables = {
CLIENT_ID = var.client_id
CLIENT_SECRET = var.client_secret
PROXY_BASE_URL = var.base_url
}
output_file_content = join("\n", [
for line in split("\n", local.input_file_content) :
format(
replace(line, "/<(${join("|", keys(local.template_variables))})>/", "%s"),
[
for value in flatten(regexall("<(${join("|", keys(local.template_variables))})>", line)) :
local.template_variables[value]
]...
)
])
}
resource "local_sensitive_file" "this" {
count = var.execution_mode == "local" ? 1 : 0
content = local.output_file_content
filename = local.enabled ? var.output_file_path : "/dev/null"
}
output "manifest_file_path" {
description = "The intended output file path"
value = var.output_file_path
}