What’s the best practice for handling this?
I want to be able to create ecs services with and without an ALB. I’m trying to create an ecs_service module that creates an ecs fargate service without an ALB and another module that attaches an ALB. Using aws_lb_target_group_attachment I cannot find a way to get the container IDs for the target_id argument.
I’m not trying to create the ALB first. Then pass a reference into my ecs service module and use make the aws_ecs_service.loadbalancer block and aws_security_group_rule ingress resource both dynamic blocks.
Being able to modularise ecs_service creation is this way seem like a common use case so I’m surprised it is this fiddly. Makes me feel I’m missing something obvious somewhere. Am I missing a general pattern? an argument or resource in the AWS provider? or something in the TF language?