Skip to content

Commit e3182f7

Browse files
author
diego
committed
refactor(Syntax for 0.12.x): Update validations for volumes and placement constraints according to n
1 parent 5fcf5be commit e3182f7

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

main.tf

+6-12
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ resource "aws_ecr_repository" "this" {
1313

1414
resource "aws_ecs_task_definition" "this" {
1515
count = "${var.network_mode != "awsvpc" ? 1 : 0}"
16-
family = "${local.id}"
16+
family = "${local.id}"
1717
container_definitions = "${data.template_file.this.rendered}"
1818
dynamic "volume" {
19-
for_each = length(var.volumes) > 0 ? list(var.volumes) : []
20-
19+
for_each = var.volumes.name != "" ? list(var.volumes) : []
2120
content {
2221
name = var.volumes.name != "" ? var.volumes.name : ""
2322
host_path = var.volumes.host_path != "" ? var.volumes.host_path : ""
@@ -27,17 +26,12 @@ resource "aws_ecs_task_definition" "this" {
2726
execution_role_arn = "${var.enable_ssm ? aws_iam_role.this.arn : ""}"
2827
requires_compatibilities = "${var.compatibilities}"
2928
dynamic "placement_constraints" {
30-
for_each = length(var.placement_constraints) > 0 ? list(var.placement_constraints) : []
29+
for_each = var.placement_constraints.type != "" ? list(var.placement_constraints) : []
3130
content {
32-
type = var.placement_constraints.type != "" ? var.placement_constraints.type : ""
33-
expression = var.placement_constraints.expression != "" ? var.placement_constraints.expression : ""
31+
type = var.placement_constraints.type
32+
expression = var.placement_constraints.expression
3433
}
3534
}
36-
# Old Definition for 0.11.x
37-
#placement_constraints {
38-
# type = "${var.placement_constraints.type}"
39-
# expression = "${var.placement_constraints.expression}"
40-
#}
4135
}
4236

4337
resource "aws_ecs_task_definition" "private" {
@@ -148,7 +142,7 @@ resource "aws_lb_listener_rule" "https" {
148142
}
149143

150144
resource "aws_ecs_service" "this" {
151-
count = "${var.balancer["vpc_id"] != "" && var.cluster != "" && var.network_mode != "awsvpc" ? 1 : 0}"
145+
count = "${var.balancer["vpc_id"] != "" && var.cluster != "" && var.network_mode != "awsvpc" && var.health_check.protocol == "TCP" ? 1 : 0}"
152146
name = "${local.id}"
153147
cluster = "${var.cluster}"
154148
task_definition = "${aws_ecs_task_definition.this.0.arn}"

0 commit comments

Comments
 (0)