1
1
/* *
2
2
* The web-service is similar to the `service` module, but the
3
- * it provides a __public__ ELB instead.
3
+ * it provides a __public__ ALB instead.
4
4
*
5
5
* Usage:
6
6
*
@@ -36,11 +36,11 @@ variable "version" {
36
36
}
37
37
38
38
variable "subnet_ids" {
39
- description = " Comma separated list of subnet IDs that will be passed to the ELB module"
39
+ description = " Comma separated list of subnet IDs that will be passed to the ALB module"
40
40
}
41
41
42
42
variable "security_groups" {
43
- description = " Comma separated list of security group IDs that will be passed to the ELB module"
43
+ description = " Comma separated list of security group IDs that will be passed to the ALB module"
44
44
}
45
45
46
46
variable "port" {
@@ -52,7 +52,7 @@ variable "cluster" {
52
52
}
53
53
54
54
variable "log_bucket" {
55
- description = " The S3 bucket ID to use for the ELB "
55
+ description = " The S3 bucket ID to use for the ALB "
56
56
}
57
57
58
58
variable "ssl_certificate_id" {
@@ -64,12 +64,12 @@ variable "iam_role" {
64
64
}
65
65
66
66
variable "external_dns_name" {
67
- description = " The subdomain under which the ELB is exposed externally, defaults to the task name"
67
+ description = " The subdomain under which the ALB is exposed externally, defaults to the task name"
68
68
default = " "
69
69
}
70
70
71
71
variable "internal_dns_name" {
72
- description = " The subdomain under which the ELB is exposed internally, defaults to the task name"
72
+ description = " The subdomain under which the ALB is exposed internally, defaults to the task name"
73
73
default = " "
74
74
}
75
75
@@ -120,6 +120,11 @@ variable "cpu" {
120
120
default = 512
121
121
}
122
122
123
+ variable "working_directory" {
124
+ description = " The working directory of the container process."
125
+ default = " /"
126
+ }
127
+
123
128
variable "deployment_minimum_healthy_percent" {
124
129
description = " lower limit (% of desired_count) of # of running tasks during a deployment"
125
130
default = 100
@@ -130,6 +135,10 @@ variable "deployment_maximum_percent" {
130
135
default = 200
131
136
}
132
137
138
+ variable vpc_id {
139
+ description = " The id of the VPC."
140
+ }
141
+
133
142
/* *
134
143
* Resources.
135
144
*/
@@ -144,9 +153,9 @@ resource "aws_ecs_service" "main" {
144
153
deployment_maximum_percent = " ${ var . deployment_maximum_percent } "
145
154
146
155
load_balancer {
147
- elb_name = " ${ module . elb . id } "
148
- container_name = " ${ module . task . name } "
149
- container_port = " ${ var . container_port } "
156
+ target_group_arn = " ${ module . alb . target_group } "
157
+ container_name = " ${ module . task . name } "
158
+ container_port = " ${ var . container_port } "
150
159
}
151
160
152
161
lifecycle {
@@ -157,13 +166,14 @@ resource "aws_ecs_service" "main" {
157
166
module "task" {
158
167
source = " ../task"
159
168
160
- name = " ${ coalesce (var. name , replace (var. image , " /" , " -" ))} "
161
- image = " ${ var . image } "
162
- image_version = " ${ var . version } "
163
- command = " ${ var . command } "
164
- env_vars = " ${ var . env_vars } "
165
- memory = " ${ var . memory } "
166
- cpu = " ${ var . cpu } "
169
+ name = " ${ coalesce (var. name , replace (var. image , " /" , " -" ))} "
170
+ image = " ${ var . image } "
171
+ image_version = " ${ var . version } "
172
+ command = " ${ var . command } "
173
+ env_vars = " ${ var . env_vars } "
174
+ memory = " ${ var . memory } "
175
+ cpu = " ${ var . cpu } "
176
+ working_directory = " ${ var . working_directory } "
167
177
168
178
ports = << EOF
169
179
[
@@ -175,8 +185,8 @@ module "task" {
175
185
EOF
176
186
}
177
187
178
- module "elb " {
179
- source = " ./elb "
188
+ module "alb " {
189
+ source = " ./alb "
180
190
181
191
name = " ${ module . task . name } "
182
192
port = " ${ var . port } "
@@ -190,38 +200,39 @@ module "elb" {
190
200
security_groups = " ${ var . security_groups } "
191
201
log_bucket = " ${ var . log_bucket } "
192
202
ssl_certificate_id = " ${ var . ssl_certificate_id } "
203
+ vpc_id = " ${ var . vpc_id } "
193
204
}
194
205
195
206
/* *
196
207
* Outputs.
197
208
*/
198
209
199
- // The name of the ELB
210
+ // The name of the ALB
200
211
output "name" {
201
- value = " ${ module . elb . name } "
212
+ value = " ${ module . alb . name } "
202
213
}
203
214
204
- // The DNS name of the ELB
215
+ // The DNS name of the ALB
205
216
output "dns" {
206
- value = " ${ module . elb . dns } "
217
+ value = " ${ module . alb . dns } "
207
218
}
208
219
209
- // The id of the ELB
210
- output "elb " {
211
- value = " ${ module . elb . id } "
220
+ // The id of the ALB
221
+ output "alb " {
222
+ value = " ${ module . alb . id } "
212
223
}
213
224
214
- // The zone id of the ELB
225
+ // The zone id of the ALB
215
226
output "zone_id" {
216
- value = " ${ module . elb . zone_id } "
227
+ value = " ${ module . alb . zone_id } "
217
228
}
218
229
219
230
// FQDN built using the zone domain and name (external)
220
231
output "external_fqdn" {
221
- value = " ${ module . elb . external_fqdn } "
232
+ value = " ${ module . alb . external_fqdn } "
222
233
}
223
234
224
235
// FQDN built using the zone domain and name (internal)
225
236
output "internal_fqdn" {
226
- value = " ${ module . elb . internal_fqdn } "
237
+ value = " ${ module . alb . internal_fqdn } "
227
238
}
0 commit comments