Skip to content

Commit 1108893

Browse files
ghaddowmarcincuber
andcommitted
Feature/lb toggle (#6)
* doh! * allow toggling of loadbalancing * Update main.tf Co-Authored-By: Marcin Cuber <[email protected]> Co-authored-by: Marcin Cuber <[email protected]>
1 parent 4313a64 commit 1108893

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [LinkedIn](http
8989
| task\_definition\_memory | The soft limit (in MiB) of memory to reserve for the container. | number | `"512"` | no |
9090
| task\_host\_port | The port number on the container instance to reserve for your container. | number | `"0"` | no |
9191
| target\_group\_name | The name for the tasks target group. | string | `""` | no |
92+
| load\_balanced | Whether the task should be loadbalanced. | bool | `true` | no |
9293

9394
## Outputs
9495

main.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,13 @@ resource "aws_ecs_service" "service" {
181181
assign_public_ip = var.task_container_assign_public_ip
182182
}
183183

184-
load_balancer {
185-
container_name = var.container_name != "" ? var.container_name : var.name_prefix
186-
container_port = var.task_container_port
187-
target_group_arn = aws_lb_target_group.task.arn
184+
dynamic "load_balancer" {
185+
for_each = var.load_balanced ? [1] : []
186+
content {
187+
container_name = var.container_name != "" ? var.container_name : var.name_prefix
188+
container_port = var.task_container_port
189+
target_group_arn = aws_lb_target_group.task.arn
190+
}
188191
}
189192

190193
deployment_controller {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,9 @@ variable "target_group_name" {
158158
default = ""
159159
description = "The name for the tasks target group"
160160
}
161+
162+
variable "load_balanced" {
163+
type = bool
164+
default = true
165+
description = "Whether the task should be loadbalanced."
166+
}

0 commit comments

Comments
 (0)