1 Answer
- Newest
- Most votes
- Most comments
0
There seems to be a problem with the ALB target group "Test1TargetGroup".
ALB target groups cannot specify alb in the target type.
Also, I think we need to create separate target groups for ALB and NLB since the same target group is used in NLB.
Change the target type of the ALB target group to "instance" or "ip" depending on your environment.
ApplicationLoadBalancer:
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
Properties:
Name: "gatling-lb"
Scheme: "internal"
Type: "application"
Subnets:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
SecurityGroups:
- !Ref ALBSecurityGroup1
IpAddressType: "ipv4"
LoadBalancerAttributes:
-
Key: "access_logs.s3.enabled"
Value: "false"
-
Key: "idle_timeout.timeout_seconds"
Value: "60"
-
Key: "deletion_protection.enabled"
Value: "false"
-
Key: "routing.http2.enabled"
Value: "true"
-
Key: "routing.http.drop_invalid_header_fields.enabled"
Value: "false"
Test1TargetGroup:
Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
Properties:
HealthCheckIntervalSeconds: 30
HealthCheckPath: "/"
Port: 80
Protocol: "HTTP"
HealthCheckPort: "traffic-port"
HealthCheckProtocol: "HTTP"
HealthCheckTimeoutSeconds: 5
UnhealthyThresholdCount: 2
TargetType: "instance"
Matcher:
HttpCode: "200"
HealthyThresholdCount: 5
VpcId: !Ref VPC
Name: "target-group-gatling"
HealthCheckEnabled: true
Targets:
- Id: !Ref Ec2
Port: 80
HTTPListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
LoadBalancerArn: !Ref ApplicationLoadBalancer
Port: 80
Protocol: "HTTP"
DefaultActions:
-
Type: "forward"
ForwardConfig:
TargetGroups:
- TargetGroupArn: !Ref Test1TargetGroup
NetworkLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: "gatling-network-lb"
Scheme: internal
Subnets:
- !Ref PrivateSubnet1
Type: network
NLBTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckEnabled: true
HealthCheckIntervalSeconds: 30
HealthCheckPath: "/"
HealthCheckPort: traffic-port
HealthCheckProtocol: HTTP
HealthyThresholdCount: 5
IpAddressType: ipv4
Name: "nlb-tg"
Port: 80
Protocol: TCP
Targets:
- Id: !Ref ApplicationLoadBalancer
Port: 80
TargetType: alb
UnhealthyThresholdCount: 2
VpcId: !Ref VPC
NetworkLoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref Test1TargetGroup
LoadBalancerArn: !Ref NetworkLoadBalancer
Port: 80
Protocol: TCP
Relevant content
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 months ago
Thanks for your reply. I have tried with different target groups for ALB and NLB as you suggested but still facing the same error while creation of NLB target group.
Sorry, there was an error in the CloudFormation template I presented. Change "TargetGroupArn" in the NLB listener from "!Ref Test1TargetGroup" to "!Ref NLBTargetGroup".