简体   繁体   English

AutoScalingGroup中的UpdatePolicy无法更新实例

[英]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.

相关问题 AWS代码部署是否可以更新现有AutoScalingGroup的启动配置? 还是使用新的LaunchConfig创建新的AutoScalingGroup? - Can AWS code deploy update an existing AutoScalingGroup's Launch Config? Or Create a new AutoScalingGroup with a new LaunchConfig? 有没有办法让AutoScalingGroup实例通过云形成待命? - Is there a way to put AutoScalingGroup instances to stand by via cloud formation? Cloudformation yaml - 在 AutoScalingGroup 资源中生成实例列表 - Cloudformation yaml- generate a list of instances in AutoScalingGroup resource 为什么在更新期间未使用AWS Cloudformation UpdatePolicy PauseTime - Why is AWS Cloudformation UpdatePolicy PauseTime not being used during an update CloudFormation AutoScalingGroup不等待更新/扩展时的信号 - CloudFormation AutoScalingGroup not waiting for signal on update/scale-up 如何使用 CloudFormation 更新 AWS::AutoScaling::AutoScalingGroup? - How do I update an AWS::AutoScaling::AutoScalingGroup using CloudFormation? AutoScalingGroup / BlockDevice - AutoScalingGroup / BlockDevice S3 触发器无法更新 DynamoDB 中的表 - S3 trigger failes to update table in DynamoDB 将 AutoscalingGroup 的 EC2 实例动态添加/删除到 AWS 仪表板指标小部件 - Dynamically adding/removing EC2 instances of an AutoscalingGroup to AWS Dashboard Metric Widget 如何控制使用Amazon Web Services通过AutoScalingGroup删除哪些EC2实例? - How can I control which EC2 instances get removed by an AutoScalingGroup using Amazon Web Services?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM