I am using CodeDeploy to deploy to an AutoScaling group behind a network load balancer, and I am running into the same issue as asked in this question.
I have tried Ref
and GetAtt
for both types of names and neither works.
Is there an actual solution to this problem?
I did a quick and successful test with an existing Target Group (of ALB) and existing AutoScaling Group. I am sharing the template below in hope it may help you figure out issue with your template:
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
If you can share your complete template, I can try to reproduce and fix.