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

时间:2019-09-28 00:07:53

标签: amazon-web-services amazon-cloudformation aws-code-deploy

我正在使用CodeDeploy部署到网络负载均衡器后面的AutoScaling组,并且遇到了this question中要求的相同问题。

对于两种类型的名称,我都尝试过RefGetAtt,但都无效。

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

1 个答案:

答案 0 :(得分:1)

我对现有的目标组(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

如果您可以共享完整的模板,我可以尝试重制和修复。