Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Scan for terminated nodes on AWS and remove from Chef
- cleanupNodes() {
- # get nodes that are terminated via aws-cli
- terminated_nodes=$(aws ec2 describe-instances --region=us-east-1 --filters Name=instance-state-name,Values=terminated | grep "InstanceId" | awk -F ":" '{print $2}' | awk -F '"' '{print $2}')
- for node in $terminated_nodes;
- do
- knife client delete ${node} -y && knife node delete ${node} -y
- done
- }
- #main
- cleanupNodes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement