# AWS Target Group unable to add multiple targets

**URL:** <https://discuss.hashicorp.com/t/aws-target-group-unable-to-add-multiple-targets/13887>\
**Category:** AWS\
**Created:** [September 8, 2020, 8:20am UTC](https://discuss.hashicorp.com/t/aws-target-group-unable-to-add-multiple-targets/13887 "2020-09-08T08:20:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sabrthor](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/sabrthor/32/10079_2.png) [@Sabrthor](https://discuss.hashicorp.com/u/Sabrthor)\
**Post date:** [September 8, 2020, 8:20am UTC](https://discuss.hashicorp.com/t/aws-target-group-unable-to-add-multiple-targets/13887/1 "2020-09-08T08:20:04Z")

</div>

Hi,  
I am trying to create ALB and Web Servers by using modules. While Web Servers and ALB gets created, I am unable to add the web servers as targets to the target group. The first one gets attached while the 2nd one fails.

```auto
Error: Error registering targets with target group: ValidationError: Instance ID ' i-0cf0a85c8866214ca' is not valid
        status code: 400, request id: 208778c2-c939-4ee5-a134-1434d1132903

```

Below are my code snippets:  
load\_balancer\main.tf

```auto
.
.
resource "aws_alb_target_group_attachment" "tg_attach" {
  count = var.tg
  target_group_arn = aws_alb_target_group.front_end_tg.arn
  port = 80
  target_id = element(split(",", var.web_server_id), count.index)
}

```

web-servers\output.tf

```auto
output "web_server_id" {
  value = join(", ", aws_instance.web.*.id)
}

```

root\main.tf

```auto
#Deploy Application Load Balancer
module "load_balancer" {
  source = "./load_balancer"
  alb_depends_on = [module.web_servers]
  pubsubnets = module.networking.public_subnets
  alb_source = module.networking.alb_source
  alb_perf = module.networking.alb_perf
  web_server_id = module.web_servers.web_server_id
  perf_vpc = module.networking.vpc_id
  tg = var.web_count
}

```

root\terraform.tfvars

```auto
web_count = 2

```

Could anyone please advise how do I make the error go away?

**AWS Console**

 ![image](https://global.discourse-cdn.com/hashicorp/original/2X/2/2558ddac2f8265b28245e9e6f0942dd6dc7c20ee.png)  
 ![image](https://global.discourse-cdn.com/hashicorp/original/2X/1/14fe4904f89c530601cdef4b95bc02511b42045d.png)

---

<div class="post-metadata">

**Author:** ![balamaran](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/balamaran/32/40840_2.png) [@balamaran](https://discuss.hashicorp.com/u/balamaran)\
**Post date:** [March 16, 2024, 8:20am UTC](https://discuss.hashicorp.com/t/aws-target-group-unable-to-add-multiple-targets/13887/2 "2024-03-16T08:20:29Z")

</div>

i am also facing the same issue; any soultion for this.  
Error registering targets with target group: ValidationError: An IP address is required  
status code: 400,
