-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapabilities.tf.tmpl
More file actions
48 lines (41 loc) · 1.29 KB
/
capabilities.tf.tmpl
File metadata and controls
48 lines (41 loc) · 1.29 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
40
41
42
43
44
45
46
47
48
{{ range . -}}
provider "ns" {
capability_name = "{{ .Name }}"
alias = "{{ .TfModuleName }}"
}
module "{{ .TfModuleName }}" {
source = "{{ .Source }}/any"
{{- if (ne .SourceVersion "latest") }}
version = "{{ .SourceVersion }}"
{{- end }}
app_metadata = local.app_metadata
{{ range $key, $value := .Variables -}}{{- if $value.HasValue }}
{{ $key }} = jsondecode({{ $value.Value | to_json_string }})
{{- end -}}{{- end }}
providers = {
ns = ns.{{ .TfModuleName }}
}
}
{{ end }}
locals {
cap_modules = [
{{- range $index, $element := .ExceptNeedsDestroyed }}
{{ if $index }}, {{ end }}{
name = "{{ $element.Name }}"
tfId = "{{ $element.TfId }}"
namespace = "{{ $element.Namespace }}"
env_prefix = "{{ $element.EnvPrefix }}"
outputs = {{ $element.TfModuleAddr }}
meta = jsondecode({{ $element.Meta | to_json_string }})
}
{{- end }}
]
cap_env_prefixes = {
for mod in local.cap_modules : mod.tfId => mod.env_prefix
}
capabilities = {
for outputName in local.capability_output_names : outputName => flatten([
for mod in local.cap_modules : [ for x in lookup(mod.outputs, outputName, []) : merge({ cap_tf_id = mod.tfId }, x) ] if contains(try(mod.meta.outputNames, []), outputName)
])
}
}