-
Notifications
You must be signed in to change notification settings - Fork 4
/
watchForImagesCreated.sh
executable file
·44 lines (35 loc) · 854 Bytes
/
watchForImagesCreated.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Awaits once images are ready with 10 minuts timeout.
TIMEOUT=600 # 10 minues
CZECH_INTERVAL=2
main(){
watchState
}
watchState(){
while true
do
czechImagesState
sleep ${CZECH_INTERVAL}
done
}
czechImagesState(){
local COLOR_GREEN=$'\e[1;32m'
local RESET_COLOR=$'\e[0m'
STOCKHOLM_STATE=`aws ec2 describe-images \
--region "eu-north-1" \
--owners "self" \
--query "Images[*].State" \
--o text`
FRANKFURT_STATE=`aws ec2 describe-images \
--region "eu-central-1" \
--owners "self" \
--query "Images[*].State" \
--o text`
[[ ${STOCKHOLM_STATE} == "available" ]] && \
[[ ${FRANKFURT_STATE} == "available" ]] && \
exit 0
(( TIMEOUT=TIMEOUT-CZECH_INTERVAL ))
(( TIMEOUT <= 0 )) && exit 1
echo -e "${COLOR_GREEN} waiting once images are created...${RESET_COLOR}"
}
./checkAWS.sh && main || ./awsCliNa.sh