Getting the error while attaching aws_alb_target_group_attachment. InvalidTarget: The following targets are not in a running state and cannot be registered
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
}
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
question from:
https://stackoverflow.com/questions/65855030/aws-terraform-error-registering-targets-with-target-group 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…