'Error While creating the Network Load Balancing in Cloud formation
Iam Trying to create Network Lode Balancing in Cloudformation But Stack it Getting fail with below error.
Error : Listener protocol 'TCP' must be one of 'HTTP, HTTPS' (Service: AmazonElasticLoadBalancingV2; Status Code: 400; Error Code: ValidationError;
# Target Group
LPTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: TCP
HealthCheckPort: 450
HealthCheckTimeoutSeconds: 10
HealthyThresholdCount: 3
Name: !Ref TargetName
TargetType: instance
Port: 450
Protocol: TCP
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '20'
Targets:
- Id:
Ref: WebEC2Instance1
Port: 450
- Id:
Ref: WebEC2Instance2
Port: 450
- Id:
Ref: WebEC2Instance3
Port: 450
UnhealthyThresholdCount: 3
VpcId:
Ref: 'Vpc'
Tags:
- Key: Name
Value: LPTargetGroup
- Key: Port
Value: 450
#ELB (NLB)
NLBListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref LPTargetGroup
LoadBalancerArn: !Ref LPNetworkLoadBalancer
Port: '80'
Protocol: TCP
Port: '443'
Protocol: TCP
LPNetworkLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: Lp-Web-NLB
Scheme: internal
Subnets:
- !Select [ 0, !Ref Subnets ]
- !Select [ 1, !Ref Subnets ]
- !Select [ 2, !Ref Subnets ]
How can i solve this?
Solution 1:[1]
Available protocols are determined by the Load Balancer type. The default type is Application Load Balancer, which supports HTTP and HTTPS protocols. If you want to use NLB you need to add Type: network
to your template.
LPNetworkLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Type: network
Name: Lp-Web-NLB
Scheme: internal
Subnets:
- !Select [ 0, !Ref Subnets ]
- !Select [ 1, !Ref Subnets ]
- !Select [ 2, !Ref Subnets ]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | oscerba |