-
Notifications
You must be signed in to change notification settings - Fork 4
/
createImages.sh
executable file
·29 lines (24 loc) · 966 Bytes
/
createImages.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
#!/bin/bash
# Creates images for the further usage with no necessity to install packages
# and docker again.
# Load values of
# STOCKHOLM_VANILLA_INSTANCE_ID & FRANKFURT_VANILLA_INSTANCE_ID
[[ -f "VANILLA_IDS.txt" ]] &&
source "VANILLA_IDS.txt" ||
exit 1
main(){
STOCKHOLM_TEMPLATE_IMAGE=`createImage "eu-north-1" ${STOCKHOLM_VANILLA_INSTANCE_ID} "template.t3.micro-0"`
echo "Stockholm template image ID:" ${STOCKHOLM_TEMPLATE_IMAGE}
echo "STOCKHOLM_TEMPLATE_IMAGE="""${STOCKHOLM_TEMPLATE_IMAGE}"" > IMAGE_IDS.txt
FRANKFURT_TEMPLATE_IMAGE=`createImage "eu-central-1" ${FRANKFURT_VANILLA_INSTANCE_ID} "template.t2.micro-0"`
echo "Frankfurt template image ID:" ${FRANKFURT_TEMPLATE_IMAGE}
echo "FRANKFURT_TEMPLATE_IMAGE="""${FRANKFURT_TEMPLATE_IMAGE}"" >> IMAGE_IDS.txt
}
createImage(){
aws ec2 create-image \
--region ${1} \
--instance-id ${2} \
--name ${3} \
| grep "ImageId" | sed -E -e 's/\ |.*:|\,//g'
}
./checkAWS.sh && main || ./awsCliNa.sh