Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error registering targets with target group: InvalidTarget: The following targets are not in a running state and cannot be registered #20345

Closed
edeas123 opened this issue Feb 14, 2019 · 2 comments

Comments

@edeas123
Copy link

Terraform Version

Terraform v0.11.11
+ provider.aws v1.54.0

Terraform Configuration Files

resource "aws_alb" "rancher-ctl-host-alb" {
	name = "rancher-ctl-host-alb"
	internal = false
	load_balancer_type = "application"
	ip_address_type  = "ipv4"

	subnets = ["${data.aws_subnet_ids.vpc_subnets.ids}"]
	security_groups = [
		"${data.terraform_remote_state.core.rancher-ctl-host-alb-sg-id}"
	]
}

# create an application load balancer listener 
resource "aws_alb_listener" "rancher-ctl-host-alb-listener" {
	load_balancer_arn = "${aws_alb.rancher-ctl-host-alb.arn}"
	port = 80
	protocol = "HTTP"

	default_action {
    	type             = "forward"
    	target_group_arn = "${aws_alb_target_group.rancher-ctl-host-target-group.arn}"
  	}
}

# create the application load balancer target group
resource "aws_alb_target_group" "rancher-ctl-host-target-group" {
	name = "rancher-ctl-host-target-group"
	port = 8080
	protocol = "HTTP"
	vpc_id = "${data.terraform_remote_state.core.default-vpc-id}"
}

# attach the three hosts to the target group
resource "aws_alb_target_group_attachment" "rancher-ctl-host-target-group-instances" {
  target_group_arn = "${aws_alb_target_group.rancher-ctl-host-target-group.arn}"
  target_id        = "${aws_spot_instance_request.rancher-ctl-host.*.spot_instance_id[count.index]}"
  port             = 8080
  count            = 3
}```

### Expected Behavior
<!--
It should not have given errors applying the plan
-->

### Actual Behavior
<!--
Error: Error applying plan:

3 error(s) occurred:

* aws_alb_target_group_attachment.rancher-ctl-host-target-group-instances[2]: 1 error(s) occurred:

* aws_alb_target_group_attachment.rancher-ctl-host-target-group-instances.2: Error registering targets with target group: InvalidTarget: The following targets are not in a running state and cannot be registered: 'i-0791f6bee8a082a10'
        status code: 400, request id: 990ee63b-3053-11e9-92bd-4d5e8013e613
* aws_alb_target_group_attachment.rancher-ctl-host-target-group-instances[0]: 1 error(s) occurred:

* aws_alb_target_group_attachment.rancher-ctl-host-target-group-instances.0: Error registering targets with target group: InvalidTarget: The following targets are not in a running state and cannot be registered: 'i-0b8c1f6d35f57c5cb'
        status code: 400, request id: 990f0dbc-3053-11e9-bbd2-3b6b83537945
* aws_alb_target_group_attachment.rancher-ctl-host-target-group-instances[1]: 1 error(s) occurred:

* aws_alb_target_group_attachment.rancher-ctl-host-target-group-instances.1: Error registering targets with target group: InvalidTarget: The following targets are not in a running state and cannot be registered: 'i-033d01746af85be03'
        status code: 400, request id: 990f3424-3053-11e9-aa19-bf12dffa0d2b
-->

### Additional Context
<!--
The problem seem to be that the alb_target_group_attachment is created before the spot instances are running (although they have been created), and it does not support interpolation which is needed in my case to use the depends_on.
-->

### References
<!--
- #12634

-->
@ghost
Copy link

ghost commented Feb 14, 2019

This issue has been automatically migrated to hashicorp/terraform-provider-aws#7561 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to hashicorp/terraform-provider-aws#7561.

@ghost ghost closed this as completed Feb 14, 2019
@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants