-
Notifications
You must be signed in to change notification settings - Fork 4
/
task.tf
151 lines (144 loc) · 4.32 KB
/
task.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
locals {
do_upload_ca_certificate_collector = var.collector_ca_certificate.value != "" ? true : false
do_configure_connection_collector = var.collector_configuration.ca_certificate != "" ? true : false
do_upload_ca_certificate_http_proxy = var.http_proxy_ca_certificate.value != "" ? true : false
do_configure_connection_http_proxy = var.http_proxy_configuration.proxy_host != "" ? true : false
}
locals {
secrets = concat(
local.do_fetch_secret_access_key ? [
{
name = "ACCESS_KEY",
valueFrom = var.access_key
}
] : [],
local.do_configure_connection_http_proxy && local.do_fetch_secret_http_proxy_password ? [
{
name = "PROXY_PASSWORD"
valueFrom = var.http_proxy_configuration.proxy_password
}
] : [],
)
environment = concat(
[
{
name = "CHECK_CERTIFICATE",
value = var.check_collector_certificate
},
{
name = "COLLECTOR",
value = var.collector_host
},
{
name = "COLLECTOR_PORT",
value = var.collector_port
},
{
name = "TAGS",
value = var.agent_tags
},
{
name = "ADDITIONAL_CONF",
value = format(
"agentino_port: %s\nlog:\n file_priority: %s\n console_priority: %s\n%s",
tostring(var.orchestrator_port),
var.agent_log_level,
var.agent_log_level,
var.agent_extra_conf
)
}
],
local.do_fetch_secret_access_key ? [] : [
{
name = "ACCESS_KEY",
value = var.access_key
}
],
local.do_upload_ca_certificate_collector ? [
{
name = "COLLECTOR_CA_CERTIFICATE_TYPE",
value = var.collector_ca_certificate.type
},
{
name = "COLLECTOR_CA_CERTIFICATE_VALUE",
value = var.collector_ca_certificate.value
},
{
name = "COLLECTOR_CA_CERTIFICATE_PATH",
value = var.collector_ca_certificate.path
},
] : [],
local.do_configure_connection_collector ? [
{
name = "COLLECTOR_CA_CERTIFICATE",
value = var.collector_configuration.ca_certificate
}
] : [],
local.do_upload_ca_certificate_http_proxy ? [
{
name = "HTTP_PROXY_CA_CERTIFICATE_TYPE",
value = var.http_proxy_ca_certificate.type
},
{
name = "HTTP_PROXY_CA_CERTIFICATE_VALUE",
value = var.http_proxy_ca_certificate.value
},
{
name = "HTTP_PROXY_CA_CERTIFICATE_PATH",
value = var.http_proxy_ca_certificate.path
},
] : [],
local.do_configure_connection_http_proxy ? [
{
name = "PROXY_HOST"
value = var.http_proxy_configuration.proxy_host
},
{
name = "PROXY_PORT"
value = var.http_proxy_configuration.proxy_port
},
{
name = "PROXY_USER"
value = var.http_proxy_configuration.proxy_user
},
{
name = "PROXY_SSL"
value = var.http_proxy_configuration.ssl
},
{
name = "PROXY_SSL_VERIFY_CERTIFICATE"
value = var.http_proxy_configuration.ssl_verify_certificate
},
{
name = "PROXY_CA_CERTIFICATE"
value = var.http_proxy_configuration.ca_certificate
},
] : [],
local.do_configure_connection_http_proxy && !local.do_fetch_secret_http_proxy_password ? [
{
name = "PROXY_PASSWORD",
value = var.http_proxy_configuration.proxy_password
},
] : []
)
}
resource "aws_ecs_task_definition" "orchestrator_agent" {
family = "${var.name}-orchestrator-agent"
execution_role_arn = aws_iam_role.orchestrator_agent_execution_role.arn
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = var.cpu
memory = var.memory
container_definitions = templatefile("${path.module}/container-definitions/orchestrator-agent.json", {
agent_image = var.agent_image
awslogs_region = data.aws_region.current_region.name
awslogs_group = "${var.name}-logs"
orchestrator_port = var.orchestrator_port
secrets = local.secrets
environment = local.environment
})
runtime_platform {
cpu_architecture = var.runtime_platform.cpu_architecture
}
tags = merge(var.tags, var.default_tags)
}