-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
210 lines (174 loc) · 5.49 KB
/
variables.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
variable "cluster_name" {
description = "Name of the ECS cluster"
type = string
}
variable "service_name" {
description = "Name of the ECS service"
type = string
}
variable "target_group_name" {
description = "Name of the ALB target group. Defaults to the `cluster_name` if not set"
type = string
default = ""
}
variable "target_group_names" {
description = "Names of the ALB target groups. Defaults to the `[cluster_name]` if not set"
type = list(string)
default = []
}
variable "target_group_arns" {
description = "ARNs of the ALB target groups. Overrides target_group_names."
type = list(string)
default = []
}
variable "fargate" {
type = bool
default = false
description = "Indicates it's going to be a Fargate service. Requires FARGATE capability of the cluster"
}
variable "fargate_spot" {
type = bool
default = false
description = "Indicates it's going to be a Fargate spot service. Requires FARGATE_SPOT capability of the cluster"
}
variable "subnet_ids" {
type = list(string)
default = []
description = "List of subnet ids. Required for Fargate tasks as they have to use awsvpc networking"
}
variable "security_groups" {
type = list(string)
default = []
description = "List of security group ids. Required for Fargate tasks as they have to use awsvpc networking"
}
variable "environment" {
description = "Enviropnment vars to pass to the container. Note: they will be visible in the task definition, so please don't pass any secrets here."
type = map(any)
default = {}
}
variable "links" {
description = "Links the main container to specified ones"
type = list(string)
default = []
}
variable "image" {
description = "The Docker image to use"
type = string
}
variable "cpu" {
description = "Amount of CPU to use"
type = number
default = 0
}
variable "essential" {
description = "Exit the task if contaner exits"
type = bool
default = true
}
variable "memory" {
description = "Amount of maximum memory the container can use"
type = number
default = 512
}
variable "memory_reservation" {
description = "Amount of reserved memory for the container"
type = number
default = 256
}
variable "container_port" {
type = number
default = 0
}
variable "load_balancer_container_name" {
description = "Name of the container that will used by the load balancer. Can be used to put nginx proxy in front of the app. Defaults to the service name"
type = string
default = ""
}
variable "additional_container_definitions" {
type = list(any)
default = []
}
variable "task_role_arn" {
type = string
default = ""
}
variable "port_mappings" {
type = list(any)
default = []
}
variable "log_configuration" {
type = object({
logDriver = string
options = map(any)
})
default = { logDriver = "", options = {} }
}
variable "readonlyRootFilesystem" {
type = bool
description = "Enforce read-only access to the file system inside of the Docker container"
default = false
}
variable "deployment_minimum_healthy_percent" {
description = "Minimum number of healty contianers during deployments"
default = 50
}
variable "deployment_maximum_percent" {
description = "Maximum number of healty contianers during deployments"
default = 200
}
variable "desired_count" {
type = number
default = 1
}
variable "init_process_enabled" {
description = "Use embdedded to Docker tini init process that correctly reaps zombie processes"
type = bool
default = true
}
variable "user" {
description = "Run container as the specified user. Formats are: user, user:group, uid, uid:gid, user:gid, uid:group"
type = string
default = ""
}
variable "use_default_capacity_provider" {
description = "Use the cluster default capacity provider"
type = bool
default = false
}
variable "efs_volumes" {
description = "Optional list of efs volumes, which are a map with {efs_id:, root_dir:}"
type = list(map(string))
default = []
}
variable "enable_execute_command" {
description = "Specifies whether to enable Amazon ECS Exec for the tasks within the service."
type = bool
default = true
}
variable "log_retention_days" {
description = "The number of days to retain log events. Set to 0 for never expire."
type = number
default = 0
}
locals {
balanced = var.container_port > 0 || length(var.port_mappings) > 0
load_balancer_container_name = coalesce(var.load_balancer_container_name, var.service_name)
target_group_names = coalescelist(distinct(compact(concat(var.target_group_names, [var.target_group_name]))), [var.cluster_name])
default_log_configuration = {
"logDriver" = "awslogs"
"options" = {
"awslogs-group" = aws_cloudwatch_log_group.main[0].name
"awslogs-region" = data.aws_region.current.name
"awslogs-stream-prefix" = var.service_name
}
}
log_awslogs = var.log_configuration["logDriver"] == ""
log_configuration = local.log_awslogs ? local.default_log_configuration : var.log_configuration
port_mappings = coalescelist(var.port_mappings, [
{
containerPort = var.container_port
}
])
use_fargate = var.fargate || var.fargate_spot
target_group_arns = local.balanced ? (length(var.target_group_arns) > 0 ? var.target_group_arns : data.aws_lb_target_group.TG[*].arn) : []
}