Skip to content

service_connect_configuration should allow multiple services #286

@AckriteTJ

Description

@AckriteTJ

Describe the Bug

The ECS module currently assumes that service_connect_configuration.service only supports a single service, which is incorrect. AWS ECS and the Terraform AWS provider both support a list of services in the service_connect_configuration.service block.

However, in the module, the dynamic block logic wraps the service_connect_configuration.service in a single-element list:

dynamic "service" {
  for_each = try([service_connect_configuration.value.service], [])
}

This causes a bug when you pass multiple services — and attempting to pass multiple fails silently or inconsistently.

Expected Behavior

The module should allow defining multiple service_connect_configuration.service, and use:

for_each = try(service_connect_configuration.value.services, [])

…instead of assuming it’s a single object.

Steps to Reproduce

Pass a list of services to service_connect_configuration.service like this:

service_connect_configuration = {
  enabled = true
  namespace = "my-namespace"
  service = [
    {
      port_name             = "http"
      discovery_name        = "http-service"
    },
    {
      port_name             = "grpc"
      discovery_name        = "grpc-service"
    }
  ]
}

Suggested Fix

In the module's ECS service definition, change:

for_each = try([service_connect_configuration.value.service], [])

…to:

for_each = try(service_connect_configuration.value.service, [])

This aligns with AWS expectations and the native aws_ecs_service resource behavior.
References

AWS ECS API: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ServiceConnectService.html

Terraform AWS Provider aws_ecs_service: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_connect_configuration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions