私の質問は、ブート可能なEC2をELBに追加する前にcfn-signal
を待つことについてです。 今のところ、ELBは準備が整うのを待つことなくインスタンスを使用して起動しますが、最悪の場合、「ブート」の最後でのみApacheサービスを開始すると、猶予期間を待たずにインスタンスを削除します終了が完了しました。ロードバランサは、このconfのでELBにブートEC2を追加する前にcfn-signalを待つ方法
"webServerASG": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"CreationPolicy": {
"ResourceSignal": {
"Timeout": "PT10M",
"Count": { "Ref": "WebServerDesiredCapacity" }
}
},
"UpdatePolicy" : {
"AutoScalingReplacingUpdate" : {
"WillReplace" : true
},
"AutoScalingRollingUpdate" : {
"MaxBatchSize" : 1,
"MinInstancesInService" : 1,
"MinSuccessfulInstancesPercent" : 75,
"SuspendProcesses" : [ "AlarmNotification", "ScheduledActions", "AZRebalance", "ReplaceUnhealthy", "HealthCheck", "Launch" ],
"WaitOnResourceSignals": true,
"PauseTime" : "PT10M"
}
},
"Properties": {
"AvailabilityZones": [...],
"Cooldown": "60",
"HealthCheckGracePeriod": "560",
"HealthCheckType": "ELB",
"MaxSize": { "Ref": "WebServerMaxCapacity" },
"MinSize": "1",
"DesiredCapacity": { "Ref": "WebServerDesiredCapacity" },
"VPCZoneIdentifier": [...],
"NotificationConfigurations": [...],
"LaunchConfigurationName": { "Ref": "webServer01LC" },
"LoadBalancerNames": [ { "Ref": "webServerLoadBalancerELB" } ],
"MetricsCollection": [...],
"TerminationPolicies": [
"Default"
]
}
},
:
"webServerLoadBalancerELB": {
"Type": "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties": {
"Subnets": [...],
"HealthCheck": {
"HealthyThreshold": "10",
"Interval": "30",
"Target": "HTTP:80/aws/healthcheck.php",
"Timeout": "5",
"UnhealthyThreshold": "2"
},
"ConnectionDrainingPolicy": {
"Enabled": "true",
"Timeout": "300"
},
"ConnectionSettings": {
"IdleTimeout": "60"
},
"CrossZone": "true",
"SecurityGroups": [...],
"Listeners": [
{
"LoadBalancerPort": "80",
"Protocol": "HTTP",
"InstancePort": "80",
"InstanceProtocol": "HTTP"
}
]
}
}
とLaunchConfigurationのために:私は私の問題を発見
"webServer01LC": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"AssociatePublicIpAddress": false,
"ImageId": {...},
"InstanceType": "t2.small",
"KeyName": {...},
"IamInstanceProfile": "EC2WebServerRole",
"SecurityGroups": [...],
"BlockDeviceMappings": [...],
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"echo '\n### pip install cloud-init : ' | tee --append /var/log//userData.log \n",
"pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz 2>> /var/log//userData.log\n",
"ln -s /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup >> /var/log//userData.log>&1\n",
"echo '\n### execute the AWS::CloudFormation::Init defined in the Metadata' | tee --append /var/log//userData.log \n",
"cfn-init -v",
" --region ", { "Ref" : "AWS::Region" },
" --stack ", { "Ref" : "AWS::StackName" },
" --resource lciTophubWebServer01LC ",
" \n",
"cfn-signal --exit-code $? --region ", { "Ref" : "AWS::Region" }, " --stack ", { "Ref" : "AWS::StackName" }, " --resource asgiTophubWebServerASG \n",
"echo '\n### end of the script!' | tee --append /var/log//userData.log \n"
]]}}
},
"Metadata": {...}
}