Created
December 5, 2019 20:30
-
-
Save ggsince88/239c852ec7ef547e6a45bf32c2508be7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Quick shell script to reboot all workspaces | |
# AWS only allows us to reboot 25 workspaces at a time | |
workspaces=(`aws workspaces describe-workspaces --directory-id ID_HERE --query 'Workspaces[*].WorkspaceId' --output text`) | |
i=0 | |
ws_array=() | |
num_of_ws=${#workspaces[@]} | |
# num of workspaces | |
echo ${num_of_ws} | |
for (( c=0; c<=${num_of_ws}; c++ )); | |
do | |
# array magic | |
ws_array+=(${workspaces[@]0:$c:1}) | |
# AWS only allows us to reboot 25 workspaces at a time | |
if [[ ${#ws_array[@]} -eq 24 ]]; then | |
echo "Rebooting workspaces" | |
aws workspaces reboot-workspaces --reboot-workspace-requests ${ws_array[@]} | |
ws_array=() | |
sleep 10 | |
elif [[ $c -eq ${num_of_ws} ]]; then | |
echo "Rebooting last of workspaces" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment