如何将ALB规则添加到现有的无服务器模板

所以我试图为/ 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)似乎是稀疏的。 我是否将这个添加到侦听器块下?

一直在调查这是如何做一个新的项目,并遇到这个例子: 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的,但是不要认为它对你以后的答案来说真的很重要。