Skip to content

Commit d4b4251

Browse files
ghaddowmarcincuber
authored andcommitted
Feature/improve tg naming (#4)
* improve tag support and expose host port * fix formatting * fix for dynamic port mapping * improve tg naming
1 parent 7a642d6 commit d4b4251

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [LinkedIn](http
8888
| task\_definition\_cpu | Amount of CPU to reserve for the task. | number | `"256"` | no |
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 |
91+
| target\_group\_name | The name for the tasks target group. | string | `""` | no |
9192

9293
## Outputs
9394

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ resource "aws_security_group_rule" "egress_service" {
7272
# Load Balancer Target group
7373
#####
7474
resource "aws_lb_target_group" "task" {
75+
name = var.target_group_name !="" ? var.target_group_name : "${var.name_prefix}-target-${var.task_container_port}"
7576
vpc_id = var.vpc_id
7677
protocol = var.task_container_protocol
7778
port = var.task_container_port
@@ -98,7 +99,7 @@ resource "aws_lb_target_group" "task" {
9899
tags = merge(
99100
var.tags,
100101
{
101-
Name = "${var.name_prefix}-target-${var.task_container_port}"
102+
Name = var.target_group_name !="" ? var.target_group_name : "${var.name_prefix}-target-${var.task_container_port}"
102103
},
103104
)
104105
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,9 @@ variable "propogate_tags" {
152152
description = "Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are SERVICE and TASK_DEFINITION."
153153
default = "TASK_DEFINITION"
154154
}
155+
156+
variable "target_group_name" {
157+
type = "string"
158+
default = ""
159+
description = "The name for the tasks target group"
160+
}

0 commit comments

Comments
 (0)