因此,我尝试为 /synchrony/* 添加一条规则,该规则将指向“synchrony”目标组。
这是我现有的模板。
ConfluenceALB:
Properties:
Scheme: internal
SecurityGroups:
- Ref: ConfluenceAlbSg
- Ref: ConfluenceAsgSg
Subnets:
- Fn::ImportValue: ${self:custom.${opt:stage}-VpcName, self:custom.${self:provider.stage}-VpcName}-PrivateSubnet1Id
- Fn::ImportValue: ${self:custom.${opt:stage}-VpcName, self:custom.${self:provider.stage}-VpcName}-PrivateSubnet2Id
- Fn::ImportValue: ${self:custom.${opt:stage}-VpcName, self:custom.${self:provider.stage}-VpcName}-PrivateSubnet3Id
Tags:
- Key: Name
Value:
Fn::Join: [ "-", [ Ref: "AWS::StackName", "confluencealb" ] ]
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
ConfluenceAlbListener:
Properties:
Certificates:
- CertificateArn: ${self:custom.${opt:stage}-SSLCertId, self:custom.${self:provider.stage}-SSLCertId}
DefaultActions:
- Type: forward
TargetGroupArn:
Ref: ConfluenceTargetGroup
LoadBalancerArn:
Ref: ConfluenceALB
Port: 443
Protocol: HTTPS
Type: AWS::ElasticLoadBalancingV2::Listener
ConfluenceTargetGroup:
Properties:
HealthCheckIntervalSeconds: 60
UnhealthyThresholdCount: 10
HealthCheckPath: /
Name: "confluence"
Port: 8080
Protocol: HTTP
VpcId:
Fn::ImportValue: ${self:custom.${opt:stage}-VpcName, self:custom.${self:provider.stage}-VpcName}-VpcId
Type: AWS::ElasticLoadBalancingV2::TargetGroup
SynchronyTargetGroup:
Properties:
Name: "synchrony"
Port: 8091
Protocol: HTTP
VpcId:
Fn::ImportValue: ${self:custom.${opt:stage}-VpcName, self:custom.${self:provider.stage}-VpcName}-VpcId
Type: AWS::ElasticLoadBalancingV2::TargetGroup
我不确定如何添加它,而且 AWS 文档 (cloudformation) 似乎很少。我应该将它添加到侦听器块下吗?
答案1
一直在研究如何为新项目完成此操作并遇到了以下示例:http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-ecs.html(尽管 AWS 文档很棒,但有时它们几乎被混淆了!)
我认为这与您相关:
ECSALBListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
DependsOn: ALBListener
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref 'ECSTG'
Conditions:
- Field: path-pattern
Values: [/]
ListenerArn: !Ref 'ALBListener'
Priority: 1
其中它指的是侦听器资源“ALBListener”和安全组“ECSTG”。该示例与 ECS 有关,但不要认为它与您想要的答案真的很重要。