Reputation: 459
I am able to launch a simple autoscaling group. However, the problem comes when I try to set up an Application Load Balancer to direct traffic to my various instances. First, I created my load balancer, it was simple as well. The problem is creating the target group and the listener. To my autoscaling group, I added the property:
TargetGroupARNs:
- !Ref AlbTargetGroup
Then, my target group is the following:
AlbTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
TargetType: ip
VpcId: ###########
Protocol: HTTP
Port: 3000
HealthCheckPath: /hello
HealthCheckIntervalSeconds: 10
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
UnhealthyThresholdCount: 2
Note that I hard-coded by VpcId. I am deploying from the CLI. In the console, the error I am getting in the Stack is:
Provided Target Group 'arn:aws:elasticloadbalancing:...' has invalid target type. Please ensure all provided Target Groups have target type of instance
Upvotes: 2
Views: 3411
Reputation: 11
TERRAFORM CASE
The answer by Typhlosaurus pointed me in the right direction. In my case, I was trying to do this same thing through Terraform, and I was getting the error
Provided Target Group (...) has invalid target type. Please ensure all provided target groups have target type of instance
This is because, as they pointed out, I was using in my Terraform configuration of the AutoScalingGroup, the attribute TargetGroupsArn, instead of the LoadBalancers one.
Upvotes: 0
Reputation: 1578
The link between Application LoadBalancer and AutoScalingGroup needs to be configured differently depending on whether the ALB TargetGroup use TargetType ip
or instance
. With instance
you use:
TargetGroupARNs:
- !Ref LoadBalancerTargetGroup
with ip
the answer depends on the actual target. For instance with ECS you typically specify it in the Service definition:
LoadBalancers:
- ContainerName: ContainerName
ContainerPort: 8080
TargetGroupArn: !Ref LoadBalancerTargetGroup
If you the instance
type ASG reference to an ip
ALBTG then you will get the Please ensure all provided Target Groups have target type of instance
error.
Upvotes: 4