-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_ec2_instance.sh
executable file
·81 lines (65 loc) · 1.54 KB
/
create_ec2_instance.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
source conf
CLUSTER=""
CONFIG=""
PROFILE=""
ENTRY_POINT=""
for i in "$@"; do
case $i in
cluster=*)
CLUSTER="${i#*=}"
;;
policy=*)
POLICY="${i#*=}"
;;
config=*)
CONFIG="${i#*=}"
;;
key=*)
KEY="${i#*=}"
;;
instance=*)
INSTANCE_TYPE="${i#*=}"
;;
region=*)
REGION="${i#*=}"
;;
entry_point=*)
ENTRY_POINT="${i#*=}"
;;
*) ;;
esac
done
# echo $CLUSTER
# echo $POLICY
# echo $CONFIG
# echo $KEY
# echo $INSTANCE_TYPE
# echo $REGION
# echo $ENTRY_POINT
function ecs_configure() {
echo "Configuring Cluster"
./ecs-cli-linux-amd64-latest configure --cluster $CLUSTER --region $REGION --default-launch-type $LAUNCH_TYPE --config-name $CONFIG
echo "Configuring Profile"
./ecs-cli-linux-amd64-latest configure profile --access-key $ACCESS_KEY --secret-key $SECRET_KEY --profile-name $PROFILE
}
function create_cluster() {
echo "Creating Cluster"
./ecs-cli-linux-amd64-latest up --keypair $KEY --capability-iam --size 1 --vpc $VPC --subnets $SUBNET --instance-type $INSTANCE_TYPE --cluster-config $CONFIG --force
}
function deploy_docker() {
echo "Deploying Docker"
./ecs-cli-linux-amd64-latest compose up --create-log-groups --cluster-config $CONFIG
}
function clean_up() {
echo "Cleaning Up"
./ecs-cli-linux-amd64-latest down --force --cluster-config $CONFIG
}
function start() {
ecs_configure
create_cluster
sleep 180
deploy_docker
sleep 60
clean_up
}
start