【问题标题】:Attaching multiple target group to AutoscalingGroup将多个目标组附加到 AutoscalingGroup
【发布时间】:2019-09-21 22:04:58
【问题描述】:

我正在设计一个基础设施解决方案来平衡 2 个不同 web 应用程序的流量,这些应用程序通过不同的路径和端口托管在同一个实例中。

我正在尝试创建一个 Cloudformation 来创建一个 ALB、1 个侦听器、2 个指向 Autoscaling Group 创建的实例的目标组,以及两个目标组的 2 个不同的侦听器规则。

正如我在 AWS 文档中所读到的,我必须在 AutoSG 属性中定义目标组,但我在定义它时遇到了问题。

我也不确定,我做对了。

我使用此代码收到错误消息(我认为这是错误的部分,当我在自动缩放组创建中对目标组进行引用时)

       "TargetGroupARNs": [
                    {
                        "Ref": "DefaultTG"
                    },
                    {
                        "Ref": "SecondTG"
                    }
        ],

这些目标群体的定义如下:

 "DefaultTG" : {
          "Type" : "AWS::ElasticLoadBalancingV2::TargetGroup",
          "Properties" : {
          "HealthCheckIntervalSeconds": 30,
          "HealthCheckProtocol": "HTTPS",
          "HealthCheckPath": "/home",
          "HealthCheckTimeoutSeconds": 10,
          "HealthyThresholdCount": 4,
          "Matcher" : {
          "HttpCode" : "200"
          },
          "Name": "Default",
          "Port": 4443,
          "Protocol": "HTTPS",
          "UnhealthyThresholdCount": 3,
          "VpcId": {"Ref" : "VpcID"}
    },

监听器代码和一个监听器规则:

   "ALBListener": {
      "Type": "AWS::ElasticLoadBalancingV2::Listener",
      "Properties": {
        "DefaultActions": [{
        "Type": "redirect",
            "RedirectConfig" : {
            "TargetGroupArn": { "Ref": "DefaultTG" }
            }
        }],
        "LoadBalancerArn": { "Ref": "APIServerELB" },
        "Port": "443",
        "Protocol": "TCP"
       }
    },
    "DefListenerRule": {
      "Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
      "Properties": {
          "Actions": [
                    {
                     "Type": "forward",
                     "TargetGroupArn": {
                     "Ref": "DefaultTG"
                    }
            }
            ],
          "Conditions" : [
                {
                  "Field" : "path-pattern",
                  "Values" : [ "/home" ]
                }
              ],
                "ListenerArn": {
                    "Ref": "ALBListener"
                }
          }
    },

错误是:

Template validation error: Invalid template resource property 'DefaultTG'

我希望 Cloudformation 创建一个带有侦听器和 2 个侦听器规则的 ALB,使用 2 个目标组指向 Autoscaling 组创建的实例。

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-elb


    【解决方案1】:

    我无法重现此内容。我的Type: 'AWS::AutoScaling::AutoScalingGroup' 中有以下内容,并且可以正常工作。

    我无法用一个 ALB 解决这个问题,所以我有两个 ALB。

    "TargetGroupARNs": [
        {
            "Ref": "DefaultTG"
        },
        {
            "Ref": "APIServerELB"
        }
    ],
    

    【讨论】:

      猜你喜欢
      • 2020-07-08
      • 2015-09-12
      • 2020-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-13
      • 2020-06-23
      • 2018-01-08
      • 1970-01-01
      相关资源
      最近更新 更多