Skip to content

Commit

Permalink
feat: add backwards compatibility to the service block
Browse files Browse the repository at this point in the history
  • Loading branch information
CaerusKaru committed Feb 9, 2024
1 parent 85a9d57 commit e9c17cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 7 additions & 9 deletions examples/fargate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,14 @@ module "ecs_service" {

service_connect_configuration = {
namespace = aws_service_discovery_http_namespace.this.arn
service = [
{
client_alias = {
port = local.container_port
dns_name = local.container_name
}
port_name = local.container_name
discovery_name = local.container_name
service = {
client_alias = {
port = local.container_port
dns_name = local.container_name
}
]
port_name = local.container_name
discovery_name = local.container_name
}
}

load_balancer = {
Expand Down
4 changes: 2 additions & 2 deletions modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ resource "aws_ecs_service" "this" {
namespace = lookup(service_connect_configuration.value, "namespace", null)

dynamic "service" {
for_each = try(service_connect_configuration.value.service, [])
for_each = try(lookup(service_connect_configuration.value.service, "port_name") != null ? [service_connect_configuration.value.service] : [], try(service_connect_configuration.value.service, []))

content {

Expand Down Expand Up @@ -339,7 +339,7 @@ resource "aws_ecs_service" "ignore_task_definition" {
namespace = lookup(service_connect_configuration.value, "namespace", null)

dynamic "service" {
for_each = try(service_connect_configuration.value.service, [])
for_each = try(lookup(service_connect_configuration.value.service, "port_name") != null ? [service_connect_configuration.value.service] : [], try(service_connect_configuration.value.service, []))

content {

Expand Down

0 comments on commit e9c17cf

Please sign in to comment.