Skip to content

Commit 5f276e6

Browse files
authored
feat: Enable integration with multiple LBs (#297)
* feat: Enable integration with multiple load balancers * feat: Make container_port optional * docs: Generate README
1 parent 884d379 commit 5f276e6

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Available targets:
154154

155155
| Name | Description | Type | Default | Required |
156156
|------|-------------|------|---------|:--------:|
157+
| <a name="input_additional_lbs"></a> [additional\_lbs](#input\_additional\_lbs) | List of additional load balancer configurations. Each config should specify container\_name (optional), container\_port (optional, defaults to main container\_port), and target\_group\_arn | <pre>list(object({<br/> container_name = optional(string)<br/> container_port = optional(number)<br/> target_group_arn = string<br/> }))</pre> | `[]` | no |
157158
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
158159
| <a name="input_alb_arn_suffix"></a> [alb\_arn\_suffix](#input\_alb\_arn\_suffix) | ARN suffix of the ALB for the Target Group | `string` | `""` | no |
159160
| <a name="input_alb_container_name"></a> [alb\_container\_name](#input\_alb\_container\_name) | The name of the container to associate with the ALB. If not provided, the generated container will be used | `string` | `null` | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
| Name | Description | Type | Default | Required |
3939
|------|-------------|------|---------|:--------:|
40+
| <a name="input_additional_lbs"></a> [additional\_lbs](#input\_additional\_lbs) | List of additional load balancer configurations. Each config should specify container\_name (optional), container\_port (optional, defaults to main container\_port), and target\_group\_arn | <pre>list(object({<br/> container_name = optional(string)<br/> container_port = optional(number)<br/> target_group_arn = string<br/> }))</pre> | `[]` | no |
4041
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
4142
| <a name="input_alb_arn_suffix"></a> [alb\_arn\_suffix](#input\_alb\_arn\_suffix) | ARN suffix of the ALB for the Target Group | `string` | `""` | no |
4243
| <a name="input_alb_container_name"></a> [alb\_container\_name](#input\_alb\_container\_name) | The name of the container to associate with the ALB. If not provided, the generated container will be used | `string` | `null` | no |

main.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,22 @@ locals {
125125
elb_name = null
126126
target_group_arn = var.nlb_ingress_target_group_arn
127127
}
128-
load_balancers = var.nlb_ingress_target_group_arn != "" ? [local.alb, local.nlb] : [local.alb]
128+
129+
additional_lbs = [
130+
for config in var.additional_lbs : {
131+
container_name = config.container_name != null ? config.container_name : module.this.id
132+
container_port = config.container_port != null ? config.container_port : var.container_port
133+
elb_name = null
134+
target_group_arn = config.target_group_arn
135+
}
136+
]
137+
138+
load_balancers = concat(
139+
[local.alb],
140+
var.nlb_ingress_target_group_arn != "" ? [local.nlb] : [],
141+
local.additional_lbs
142+
)
143+
129144
init_container_definitions = [
130145
for init_container in var.init_containers : init_container["container_definition"]
131146
]

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,3 +1141,13 @@ variable "circuit_breaker_rollback_enabled" {
11411141
description = "If `true`, Amazon ECS will roll back the service if a service deployment fails"
11421142
default = false
11431143
}
1144+
1145+
variable "additional_lbs" {
1146+
type = list(object({
1147+
container_name = optional(string)
1148+
container_port = optional(number)
1149+
target_group_arn = string
1150+
}))
1151+
description = "List of additional load balancer configurations. Each config should specify container_name (optional), container_port (optional, defaults to main container_port), and target_group_arn"
1152+
default = []
1153+
}

0 commit comments

Comments
 (0)