Skip to content

Commit bdd3c0a

Browse files
ovcharenkojnonino
andauthored
[ADD] Optional tags (#25)
Co-authored-by: Julian Nonino <[email protected]>
1 parent 20945df commit bdd3c0a

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

main.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ module "ecs-alb" {
4848
default_certificate_arn = var.default_certificate_arn
4949
ssl_policy = var.ssl_policy
5050
additional_certificates_arn_for_https_listeners = var.additional_certificates_arn_for_https_listeners
51+
52+
# Optional tags
53+
tags = var.tags
5154
}
5255

5356
#------------------------------------------------------------------------------
@@ -112,9 +115,12 @@ resource "aws_ecs_service" "service" {
112115
}
113116
}
114117
task_definition = var.task_definition_arn
115-
tags = {
116-
Name = "${var.name_prefix}-ecs-tasks-sg"
117-
}
118+
tags = merge(
119+
var.tags,
120+
{
121+
Name = "${var.name_prefix}-ecs-tasks-sg"
122+
},
123+
)
118124
}
119125

120126
#------------------------------------------------------------------------------
@@ -125,9 +131,12 @@ resource "aws_security_group" "ecs_tasks_sg" {
125131
description = "Allow inbound access from the LB only"
126132
vpc_id = var.vpc_id
127133

128-
tags = {
129-
Name = "${var.name_prefix}-ecs-tasks-sg"
130-
}
134+
tags = merge(
135+
var.tags,
136+
{
137+
Name = "${var.name_prefix}-ecs-tasks-sg"
138+
},
139+
)
131140
}
132141

133142
resource "aws_security_group_rule" "egress" {
@@ -176,4 +185,5 @@ module "ecs-autoscaling" {
176185
min_cpu_period = var.min_cpu_period
177186
scale_target_max_capacity = var.scale_target_max_capacity
178187
scale_target_min_capacity = var.scale_target_min_capacity
188+
tags = var.tags
179189
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ variable "desired_count" {
3737
default = 1
3838
}
3939

40+
variable "tags" {
41+
type = map(string)
42+
default = {}
43+
description = "Resource tags"
44+
}
45+
4046
variable "enable_ecs_managed_tags" {
4147
description = "(Optional) Specifies whether to enable Amazon ECS managed tags for the tasks within the service."
4248
type = bool

0 commit comments

Comments
 (0)