Skip to content

Commit

Permalink
feat: Add var service_tags (#159)
Browse files Browse the repository at this point in the history
* add var service_tags

* add example service_tags

---------

Co-authored-by: Leonardo Biffi <leonardo.biffi@4all.com>
  • Loading branch information
leonardobiffi and Leonardo Biffi committed Jan 29, 2024
1 parent ccc0d3a commit 1290240
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions examples/fargate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ module "ecs_service" {
}
}

service_tags = {
"ServiceTag" = "Tag on service level"
}

tags = local.tags
}

Expand Down
1 change: 1 addition & 0 deletions modules/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ module "ecs_service" {
| <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 |
| <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 |
| <a name="input_service_registries"></a> [service\_registries](#input\_service\_registries) | Service discovery registries for the service | `any` | `{}` | no |
| <a name="input_service_tags"></a> [service\_tags](#input\_service\_tags) | A map of additional tags to add to the service | `map(string)` | `{}` | no |
| <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 |
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnets to associate with the task or service | `list(string)` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ resource "aws_ecs_service" "this" {
wait_for_steady_state = var.wait_for_steady_state

propagate_tags = var.propagate_tags
tags = var.tags
tags = merge(var.tags, var.service_tags)

timeouts {
create = try(var.timeouts.create, null)
Expand Down
6 changes: 6 additions & 0 deletions modules/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ variable "wait_for_steady_state" {
default = null
}

variable "service_tags" {
description = "A map of additional tags to add to the service"
type = map(string)
default = {}
}

################################################################################
# Service - IAM Role
################################################################################
Expand Down
1 change: 1 addition & 0 deletions wrappers/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ module "wrapper" {
security_group_use_name_prefix = try(each.value.security_group_use_name_prefix, var.defaults.security_group_use_name_prefix, true)
service_connect_configuration = try(each.value.service_connect_configuration, var.defaults.service_connect_configuration, {})
service_registries = try(each.value.service_registries, var.defaults.service_registries, {})
service_tags = try(each.value.service_tags, var.defaults.service_tags, {})
skip_destroy = try(each.value.skip_destroy, var.defaults.skip_destroy, null)
subnet_ids = try(each.value.subnet_ids, var.defaults.subnet_ids, [])
tags = try(each.value.tags, var.defaults.tags, {})
Expand Down

0 comments on commit 1290240

Please sign in to comment.