引用 AWS::CodeDeploy::DeploymentGroup::LoadBalancerInfo 的正确方法是什么?

What is the correct way to reference `AWS::CodeDeploy::DeploymentGroup::LoadBalancerInfo?`

我正在使用 CodeDeploy 部署到网络负载均衡器后面的 AutoScaling 组,我 运行 遇到了与 this question.

中询问的相同问题

我已经尝试了 RefGetAtt 这两种类型的名称,但都不起作用。

这个问题有实际的解决方案吗?

我对现有目标组(ALB)和现有 AutoScaling 组进行了快速且成功的测试。我正在分享下面的模板,希望它可以帮助您解决模板问题:

Parameters:
  DeploymentGroupName:
    Type: String
    Default: "MyDeploymentGroupName"
  VpcCidr:
    Type: String
    Default: "10.10.0.0/16"
  SubnetCidr:
    Type: String
    Default: "10.10.1.0/24"

Resources:
  myVpc:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref VpcCidr

  mySubnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref myVpc
      CidrBlock: !Ref SubnetCidr

  InternetGateway:
    Type: AWS::EC2::InternetGateway

  AttachGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref myVpc
      InternetGatewayId: !Ref InternetGateway

  mySNSTopic:
    Type: AWS::SNS::Topic
    Properties: {}

  Application:
    Type: AWS::CodeDeploy::Application

  DeploymentConfig:
    Type: AWS::CodeDeploy::DeploymentConfig
    Properties:
      MinimumHealthyHosts:
        Type: FLEET_PERCENT
        Value: '25'

  DeploymentGroup:
    Type: AWS::CodeDeploy::DeploymentGroup
    Properties:
      ApplicationName: !Ref Application
      DeploymentConfigName: !Ref DeploymentConfig
      DeploymentGroupName: !Ref DeploymentGroupName
      AutoScalingGroups: 
        - "MyASGName"      
      LoadBalancerInfo:
       TargetGroupInfoList: 
          - Name: MYALBTargetGrpName
      DeploymentStyle:
        DeploymentOption: WITH_TRAFFIC_CONTROL
      ServiceRoleArn: arn:aws:iam::<acc_number>:role/MyCodeDeployServiceRole
      TriggerConfigurations:
        - TriggerEvents:
            - DeploymentSuccess
            - DeploymentFailure
          TriggerName: MyTarget
          TriggerTargetArn: !Ref mySNSTopic

如果你能分享你的完整模板,我可以尝试重现并修复。