简体   繁体   English

在CloudFormation中的多个LoadBalancers之后添加实例?

[英]Adding instances behind multiple LoadBalancers in CloudFormation?

I am trying to figure out a way to add a ec2 node to two load balancers, but am not finding a sane way to do it. 我正在尝试找出一种将ec2节点添加到两个负载均衡器的方法,但是没有找到一种明智的方法来做到这一点。 I would think that the below code would allow me to do this, but am not getting my expected results 我认为下面的代码将允许我执行此操作,但未获得预期的结果

Please note that this code is HIGHLY stripped down to just show the LB portion. 请注意,此代码已高度精简以仅显示LB部分。

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": " App Demo / Jd / 01042016",
  "Parameters": {
    "LoadBalancers": {
      "Description": "Please refer the LoadBalancerNames which you want the instances to be registered to",
      "Type": "List<AWS::EC2::LoadBalancers::LoadBalancerNames>",
      "Default": "web-app-demo-ext,web-api-demo-ext"
    }
  },
  "Resources": {
    "AppAutoScalingGroup": {
      "Type": "AWS::AutoScaling::AutoScalingGroup",
      "Properties": {
        "AvailabilityZones": {
          "Ref": "AZs"
        },
        "LoadBalancerNames": [{
          "Ref": "LoadBalancers"
        }]
      }
    }
  }
}

I would expect to see a list which I can add multiple LBs to, but I am instead seeing a normal input box (string) 我希望看到一个可以添加多个LB的列表,但我看到的是一个普通的输入框(字符串)

Adding in images with some firebug hackery.... 添加带有萤火虫黑客的图像。

Expected Results 预期成绩 预期成绩

What actually happens 实际发生了什么 我实际上得到了什么

UPDATE 更新

After fudging with Cloud Designer, I believe that "Type": "List<AWS::EC2::LoadBalancers::LoadBalancerNames>" is incorrect and should really be "Type": "List<AWS::ElasticLoadBalancing::LoadBalancer>" 在使用Cloud Designer进行伪造之后,我认为"Type": "List<AWS::EC2::LoadBalancers::LoadBalancerNames>"是不正确的,并且实际上应该是"Type": "List<AWS::ElasticLoadBalancing::LoadBalancer>"

This still does not propagate as a list though 虽然这仍然不会传播为列表

Figured it out. 弄清楚了。 You will need multiple references. 您将需要多个参考。 And the reason is because the "LoadBalancerNames" key can take multiple references, like so: "LoadBalancerNames": { "Foo", "Bar" } 原因是因为"LoadBalancerNames"键可以采用多个引用,例如: "LoadBalancerNames": { "Foo", "Bar" }

Really hope this helps someone else as it had me scratching my head for days :) 真希望这能对别人有所帮助,因为它让我me了好几天的头:)

{
  ................
  "Parameters": {
    .......
    "LoadBalancerApp": {
      "Description": "Please refer the LoadBalancerNames (APP) which you want the instances to be registered to",
      "Type": "String",
      "Default": "web-app-demo-ext"
    },
    "LoadBalancerApi": {
      "Description": "Please refer the LoadBalancerNames (API) which you want the instances to be registered to",
      "Type": "String",
      "Default": "web-api-demo-ext"
    },
    .......
  },
  "Resources": {
    ........
    "AppnameAutoScalingGroup": {
      "Type": "AWS::AutoScaling::AutoScalingGroup",
      "Properties": {
        "AvailabilityZones": {
          "Ref": "AZs"
        },
        "LaunchConfigurationName": {
          "Ref": "AppnameLaunchConfig"
        },
        "LoadBalancerNames": [{
          "Ref": "LoadBalancerApp"
        }, {
          "Ref": "LoadBalancerApi"
        }],
    ..........
}

This won't give you the UI you were looking for, but it will allow you to specify multiple load balancer names in a single parameter. 这不会为您提供所需的用户界面,但是它将允许您在单个参数中指定多个负载均衡器名称。

Use CommaDelimitedList as the parameter type. 使用CommaDelimitedList作为参数类型。

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": " App Demo / Jd / 01042016",
  "Parameters": {
    "LoadBalancers": {
      "Description": "Please refer the LoadBalancerNames which you want the instances to be registered to",
      "Type": "CommaDelimitedList",
      "Default": "web-app-demo-ext,web-api-demo-ext"
    }
  },
  "Resources": {
    "AppAutoScalingGroup": {
      "Type": "AWS::AutoScaling::AutoScalingGroup",
      "Properties": {
        "AvailabilityZones": {
          "Ref": "AZs"
        },
        "LoadBalancerNames": {
          "Ref": "LoadBalancers"
        }
      }
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用CloudFormation将LoadBalancers批量添加到AutoScaling组 - Batch add LoadBalancers to AutoScaling Groups with CloudFormation 有没有办法在不使用负载均衡器的情况下将Ela​​stic Beanstalk与多个ec2实例一起使用 - Is there a way to use Elastic Beanstalk with multiple ec2 instances with out using loadbalancers AWS ECS:ECSService CloudFormation 资源定义中的 LoadBalancers 属性错误 - AWS ECS: LoadBalancers property error in ECSService CloudFormation resource definition 为多个实例重用AWS :: CloudFormation :: Init(和userdata?) - Reusing AWS::CloudFormation::Init (and userdata?) for multiple instances 如果可以使用AWS Cloudformation模板将Loadbalancers DNSname连接到Route53? - If it possible connect Loadbalancers DNSname to Route53 using AWS Cloudformation template? CloudFormation Windows实例引导 - CloudFormation Windows Instances Bootstrapping 我可以在Route53 Alias记录中使用多个LoadBalancers吗? - Can I use multiple LoadBalancers in Route53 Alias records? CloudFormation 条件 EMR 实例 - CloudFormation conditional EMR instances 在 CloudFormation 中部署 AWS::EKS::Nodegroup 时向 EC2 实例添加名称 - Adding name to EC2 instances when deploying AWS::EKS::Nodegroup in CloudFormation 由LaunchConfig创建的实例的CloudFormation标记 - CloudFormation tags for instances created by LaunchConfig
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM