(MODE-11365) Added comment to explain local-exec command.
This commit is contained in:
parent
0c32f2bcd0
commit
26e8d13213
1 changed files with 2 additions and 3 deletions
|
|
@ -47,9 +47,8 @@ resource "aws_autoscaling_group" "autoscalinggroup" {
|
|||
}
|
||||
|
||||
provisioner "local-exec" {
|
||||
# Wait until the number of "ok" instance status checks is equal to 1
|
||||
# command = "sleep 15;expected=2; current=0; retries=0; instances=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name \"${aws_autoscaling_group.autoscalinggroup.name}\" --query 'AutoScalingGroups[*].Instances[*].InstanceId' --output text); while [ \"$current\" -lt \"$expected\" ]; do for i in $(echo $instances); do check=$(aws elbv2 describe-target-health --target-group-arn \"${aws_alb_target_group.target_group_this.arn}\" --query \"TargetHealthDescriptions[?Target.Id == '$i'].TargetHealth.State\" --output text); echo \"$check\"; if [ \"$check\" = \"$(echo 'healthy')\" ]; then current=\"$(echo $((++current)))\"; else current=\"$(echo $((--current)))\"; fi; done; if [ \"$current\" -eq \"$expected\" ]; then break; else current=\"0\"; retries=\"$((++retries))\" fi; if [ \"$retries\" = \"3\" ]; then break;fi; done"
|
||||
# command = "sleep 15;expected=2; current=0; retries=0; instances=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name \"${aws_autoscaling_group.autoscalinggroup.name}\" --query 'AutoScalingGroups[*].Instances[*].InstanceId' --output text); while [ \"$current\" -lt \"$expected\" ]; do for i in $(echo $instances); do check=$(aws elbv2 describe-target-health --target-group-arn \"${aws_alb_target_group.target_group_this.arn}\" --query \"TargetHealthDescriptions[?Target.Id == '$i'].TargetHealth.State\" --output text); echo \"$check\"; if [ \"$check\" = \"$(echo 'healthy')\" ]; then current=\"$(echo $((++current)))\"; else current=\"$(echo $((--current)))\"; fi; done; if [ \"$current\" -eq \"$expected\" ]; then break; else current=\"0\"; retries=\"$((++retries))\" fi; if [ \"$retries\" = \"3\" ]; then break;fi; done"
|
||||
# Unwrap to read
|
||||
# For every instance of the autoscaling group wait to get 3 "healthy" checks efore taking down the old autoscaling group
|
||||
command = "echo \"Waiting for instances spinup (2m)\"; sleep 120; current=0; required=3; instances=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name \"${aws_autoscaling_group.autoscalinggroup.name}\" --query 'AutoScalingGroups[*].Instances[*].InstanceId' --output text); for i in $(echo $instances); do check=$(aws elbv2 describe-target-health --target-group-arn \"${aws_alb_target_group.target_group_this.arn}\" --query \"TargetHealthDescriptions[?Target.Id == '$i'].TargetHealth.State\" --output text); while true; if [ \"$current\" == \"$required\" ]; then break;fi; if [ \"$check\" == \"healthy\" ]; then current=$((++current)); fi; do echo \"check = $check\"; echo \"Waiting for instance $i startup\"; sleep 15; check=$(aws elbv2 describe-target-health --target-group-arn \"${aws_alb_target_group.target_group_this.arn}\" --query \"TargetHealthDescriptions[?Target.Id == '$i'].TargetHealth.State\" --output text); done; current=0; done; echo \"Got 3 healthy checks in a row, proceeding...\"; sleep 10"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue