cleanup ec2: Ignore terminated instances

If users had previously terminated an instance and recreated it, e.g
manually in the console, the clean-up script will have issues since
terminated instance remain available in AWS some time. This commit
only takes instances with a state of stopped or running for termination.
pull/101/head
joshrosso 2016-11-17 08:32:35 -08:00
parent 0450e2b3b7
commit bffb753b1b
1 changed files with 1 additions and 1 deletions

View File

@ -67,7 +67,7 @@ KUBERNETES_HOSTS=(controller0 controller1 controller2 worker0 worker1 worker2)
```
for host in ${KUBERNETES_HOSTS[*]}; do
INSTANCE_ID=$(aws ec2 describe-instances \
--filters "Name=tag:Name,Values=${host}" | \
--filters "Name=tag:Name,Values=${host}" "Name=instance-state-name,Values=running,stopped" | \
jq -j '.Reservations[].Instances[].InstanceId')
aws ec2 terminate-instances --instance-ids ${INSTANCE_ID}
done