我希望你已经解决了这个问题。但是,以防其他人来这里寻找同样的问题。
基本上,你没有做错什么。就是这样,你需要一个
目标群体
负载平衡器侦听器
以下是TargetGroup资源的示例:
...
ExampleTG:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
HealthCheckPath: /healthcheck
HealthCheckPort: 80
Matcher:
HttpCode: '200'
Name: !Join [ "-", [ Example, !Ref SomeParameter] ]
Port: 80
Protocol: HTTP
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '15'
UnhealthyThresholdCount: 3
VpcId:
'Fn::ImportValue': !Sub '${ParentVPCStack}-vpc'
...
ExampleListernerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref ExampleTG
Conditions:
- Field: host-header
Values:
- "example.*"
ListenerArn:
'Fn::ImportValue': !Sub '${ParentLBStack}-existing-listener'
Priority: 1
您可以轻松地从现有堆栈导入侦听器[ELBv2在您的示例中],该堆栈将负载平衡器与目标组相关联。