Creating aws_ecs_service fails with target group error

up until now I would have created ecs clusters manually with AWS GUI.
I would first create a Load balancer then creating ecs task definition and a service, in the service creation process I would pick the load balancer I have created in previous steps.

Now I would like to automate the process using terraform and I get the following:
“InvalidParameterException: The target group with targetGroupArn arn:xxx does not have an associated load balancer”
in terraform there is a resource aws_lb_target_group_attachment but it requires containes_ids which I do not need to supply in the GUI method.
in terraform I did not find a way in the resource aws_ecs_service to attach a load balancer so the error make sense, so how would I accomplish the task?


In case it interest anyone, I think I found what was the problem for me.
so the main thing was where do I connect the loadbalancer with the target group. the aws_lb_listener resource was the way to go for me.