Skip to content

Commit 1290240

Browse files
leonardobiffiLeonardo Biffi
and
Leonardo Biffi
authored
feat: Add var service_tags (#159)
* add var service_tags * add example service_tags --------- Co-authored-by: Leonardo Biffi <[email protected]>
1 parent ccc0d3a commit 1290240

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

examples/fargate/main.tf

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ module "ecs_service" {
163163
}
164164
}
165165

166+
service_tags = {
167+
"ServiceTag" = "Tag on service level"
168+
}
169+
166170
tags = local.tags
167171
}
168172

modules/service/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ module "ecs_service" {
287287
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`security_group_name`) is used as a prefix | `bool` | `true` | no |
288288
| <a name="input_service_connect_configuration"></a> [service\_connect\_configuration](#input\_service\_connect\_configuration) | The ECS Service Connect configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace | `any` | `{}` | no |
289289
| <a name="input_service_registries"></a> [service\_registries](#input\_service\_registries) | Service discovery registries for the service | `any` | `{}` | no |
290+
| <a name="input_service_tags"></a> [service\_tags](#input\_service\_tags) | A map of additional tags to add to the service | `map(string)` | `{}` | no |
290291
| <a name="input_skip_destroy"></a> [skip\_destroy](#input\_skip\_destroy) | If true, the task is not deleted when the service is deleted | `bool` | `null` | no |
291292
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnets to associate with the task or service | `list(string)` | `[]` | no |
292293
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |

modules/service/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ resource "aws_ecs_service" "this" {
191191
wait_for_steady_state = var.wait_for_steady_state
192192

193193
propagate_tags = var.propagate_tags
194-
tags = var.tags
194+
tags = merge(var.tags, var.service_tags)
195195

196196
timeouts {
197197
create = try(var.timeouts.create, null)

modules/service/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ variable "wait_for_steady_state" {
188188
default = null
189189
}
190190

191+
variable "service_tags" {
192+
description = "A map of additional tags to add to the service"
193+
type = map(string)
194+
default = {}
195+
}
196+
191197
################################################################################
192198
# Service - IAM Role
193199
################################################################################

wrappers/service/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ module "wrapper" {
9191
security_group_use_name_prefix = try(each.value.security_group_use_name_prefix, var.defaults.security_group_use_name_prefix, true)
9292
service_connect_configuration = try(each.value.service_connect_configuration, var.defaults.service_connect_configuration, {})
9393
service_registries = try(each.value.service_registries, var.defaults.service_registries, {})
94+
service_tags = try(each.value.service_tags, var.defaults.service_tags, {})
9495
skip_destroy = try(each.value.skip_destroy, var.defaults.skip_destroy, null)
9596
subnet_ids = try(each.value.subnet_ids, var.defaults.subnet_ids, [])
9697
tags = try(each.value.tags, var.defaults.tags, {})

0 commit comments

Comments
 (0)