-
Notifications
You must be signed in to change notification settings - Fork 0
/
locals.tf
102 lines (88 loc) · 3.29 KB
/
locals.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
locals {
tags_merged = merge(
{
"Name" = format("%s", var.environment)
},
{
"Environment" = format("%s", var.environment)
},
var.tags,
)
tags = { for k, v in local.tags_merged : k => v if !contains(var.suppressed_tags, k) }
runner_docker_options = {
arm64 = merge({
for key, value in var.runner_docker_options_arm64 : key => value if value != null
}, {})
amd64 = merge({
for key, value in var.runner_docker_options_amd64 : key => value if value != null
}, {})
}
runner_autoscaler_options = {
arm64 = merge({
for key, value in var.runner_autoscaler_options_arm64 : key => value if value != null
}, {})
amd64 = merge({
for key, value in var.runner_autoscaler_options_amd64 : key => value if value != null
}, {})
}
runner_autoscaler_plugin_connector_options = {
arm64 = merge({
for key, value in var.runner_autoscaler_plugin_connector_options_arm64 : key => value if value != null
}, {})
amd64 = merge({
for key, value in var.runner_autoscaler_plugin_connector_options_amd64 : key => value if value != null
}, {})
}
runner_autoscaler_plugin_options = {
arm64 = merge({
for key, value in var.runner_autoscaler_plugin_options_arm64 : key => value if value != null
}, { name = try(aws_autoscaling_group.gitlab_runner_instance["arm64"].name, null) })
amd64 = merge({
for key, value in var.runner_autoscaler_plugin_options_amd64 : key => value if value != null
}, { name = try(aws_autoscaling_group.gitlab_runner_instance["amd64"].name, null) })
}
runner_autoscaler_policy_arm64_cleaned = [
for policy in var.runner_autoscaler_policy_arm64 : {
for key, value in policy : key => value if value != null
}
]
runner_autoscaler_policy_amd64_cleaned = [
for policy in var.runner_autoscaler_policy_amd64 : {
for key, value in policy : key => value if value != null
}
]
runner_autoscaler_policy = {
arm64 = local.runner_autoscaler_policy_arm64_cleaned
amd64 = local.runner_autoscaler_policy_amd64_cleaned
}
runner_tokens = {
arm64 = var.runner_ssm_token_arm64
amd64 = var.runner_ssm_token_amd64
}
runner_instances = {
amd64 = var.runner_instance_amd64
arm64 = var.runner_instance_arm64
}
template_runner_config = templatefile("${path.module}/templates/runner_manager.tftpl",
{
gitlab_check_interval = var.runner_manager.gitlab_check_interval
maximum_concurrent_jobs = var.runner_manager.maximum_concurrent_jobs
prometheus_listen_address = var.runner_manager.prometheus_listen_address
sentry_dsn = var.runner_manager.sentry_dsn
runners_autoscaling = [
for arch in var.architectures : {
name = format("runner-%s", arch)
url = var.gitlab_instance_url
token = local.runner_tokens[arch].name
shell = "sh"
plugin = "fleeting-plugin-aws"
docker = local.runner_docker_options[arch]
autoscaler = local.runner_autoscaler_options[arch]
connector_config = local.runner_autoscaler_plugin_connector_options[arch]
plugin_config = local.runner_autoscaler_plugin_options[arch]
policy = local.runner_autoscaler_policy[arch]
}
]
}
)
}