[英]UpdatePolicy in AutoScalingGroup failes to update instances
I have used the following settings in the CloudFormation for creating an autoscaling group: 我在CloudFormation中使用了以下设置来创建自动缩放组:
"myautoscalinggroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"UpdatePolicy" : {
"AutoScalingRollingUpdate" : {
"MinInstancesInService" : "1",
"MaxBatchSize" : "2",
"WaitOnResourceSignals" : "true",
"PauseTime" : "PT5M"
}
},
"Properties": {
"AvailabilityZones": [
"ap-southeast-2b",
"ap-southeast-2a"
],
"Cooldown": "300",
"DesiredCapacity": { "Ref" : "InstanceCount"},
"HealthCheckGracePeriod": "300",
"HealthCheckType": "EC2",
"MaxSize": "5",
"MinSize": "1",
"VPCZoneIdentifier": { "Ref" : "WebServerSubnets" },
"LaunchConfigurationName": {
"Ref": "mylaunchconfiguration"
},
"LoadBalancerNames": [
{
"Ref": "myloadbalancer"
}
],
"TerminationPolicies": [
"Default"
]
}
},
"mylaunchconfiguration": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"Comment": "Get web page",
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
"yum" : {
"httpd" : []
}
},
"sources" : {
"/var/www/html" : "address to web-site contents"
},
"services" : {
"sysvinit" : {
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
}
}
}
}
},
"Properties": {
"ImageId": "ami-fd9cecc7",
"InstanceType": "t2.micro",
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe\n",
"yum update -y aws-cfn-bootstrap\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource mylaunchconfiguration ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"/opt/aws/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource myautoscalinggroup ",
" --region ", { "Ref" : "AWS::Region" }, "\n"
]]}},
"KeyName": "myKey",
"SecurityGroups": [{ "Ref" : "mySecurityGroup" }],
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"VolumeSize": 8
}
}
]
}
}
But the update policy fails to update instances when I update the stack with a new launch configuration. 但是,当我使用新的启动配置更新堆栈时,更新策略无法更新实例。 But when I terminate the instances manually, the AutoScalingGroup kicks in and starts new instances with the updated LaunchConfiguration.
但是,当我手动终止实例时,AutoScalingGroup会启动并使用更新的LaunchConfiguration启动新实例。 Any idea on how to get the update policy working?
关于如何使更新策略生效的任何想法?
Thanks 谢谢
The AutoScaling UpdatePolicy will not be triggered by a change to the LaunchConfiguration Metadata. 更改LaunchConfiguration元数据不会触发AutoScaling UpdatePolicy。 You will need to make a change to a LaunchConfiguration property to trigger the UpdatePolicy.
您将需要对LaunchConfiguration属性进行更改以触发UpdatePolicy。 The easiest way to do this is to make a simple change to the UserData.
最简单的方法是对UserData进行简单的更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.