-
Notifications
You must be signed in to change notification settings - Fork 2
/
launch_instances.sh
61 lines (45 loc) · 1.38 KB
/
launch_instances.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# launch_instances.sh
#
# Copyright(c) 2013 Uptime Technologies, LLC.
MASTER_EIP=54.238.126.147
SLAVE_EIP=54.238.127.37
. ./env.sh
function launch_instances()
{
cat /dev/null > /tmp/ec2-run-instances.log
echo "Launching an instance in ap-northeast-1a..."
ec2-run-instances ami-39b23d38 --region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
-k uptime_snaga \
-g uptime-ssh -g test-pgsql \
--instance-type t1.micro \
--availability-zone ap-northeast-1a \
| tee -a /tmp/ec2-run-instances.log
echo "Launching an instance in ap-northeast-1b..."
ec2-run-instances ami-39b23d38 --region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
-k uptime_snaga \
-g uptime-ssh -g test-pgsql \
--instance-type t1.micro \
--availability-zone ap-northeast-1b \
| tee -a /tmp/ec2-run-instances.log
}
function assign_eips()
{
echo "Assigning $MASTER_EIP to $MASTER..."
ec2-associate-address --region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
-i $MASTER \
$MASTER_EIP
echo "Assigning $SLAVE_EIP to $SLAVE..."
ec2-associate-address --region ap-northeast-1 \
-O $AWS_ACCESS_KEY -W $AWS_SECRET_KEY \
-i $SLAVE \
$SLAVE_EIP
}
launch_instances
MASTER=`grep ^INSTANCE /tmp/ec2-run-instances.log | awk '{ print $2 }' | head -1`
SLAVE=`grep ^INSTANCE /tmp/ec2-run-instances.log | awk '{ print $2 }' | tail -1`
./check_instances.sh
assign_eips