-
Notifications
You must be signed in to change notification settings - Fork 1
/
cf-kibana
executable file
·116 lines (97 loc) · 3.35 KB
/
cf-kibana
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#
# Create a Kibana stack.
export TMP=/tmp/cli
##
# Validate parameters.
##
if [ $# -lt 3 ]
then
echo Usage:
echo ' ' \<thisfile\> \<stack\> \<space\> \<guipassword\>
echo where
echo ' ' \<stack\> is any string,
echo ' ' \<space\> is either int, dev, test, stage or prod,
echo ' ' \<guipassword\> is any string
exit 1
fi
stack=$1
space=$2
guipassword=$3
if [[ \
$space = 'int' || $space = 'test' || \
$space = 'dev' || $space = 'stage' || \
$space = 'prod' ]]; then
echo thanks
else
echo The space parameter value must be either int, dev, test, stage or prod.
exit 1
fi
if [ $space = 'prod' ]; then
gstype='gsp'
else
if [[ \
$space = 'int' || $space = 'test' || \
$space = 'dev' || $space = 'stage' ]]; then
gstype='gsn'
else
echo Space must be either int, test, dev, stage or prod. It''s ${space}
exit 1
fi
fi
##
# Modify Kibana's Elasticsearch's instances' security group.
##
./elasticsearch ${space} &> $TMP-0900
##
# Look up values to be passed into CloudFormation.
##
if [ $gstype = 'gsp' ]; then
vpcid=$( \
aws ec2 describe-vpcs --filter Name=tag:Name,Values="gsp-vpc" \
--region us-east-1 --query Vpcs[].VpcId --output text) &> $TMP-1000
subnetid=$( \
aws ec2 describe-subnets --filters Name=tag:Name,"Values=gsp-vpc: public A" \
--region us-east-1 --query Subnets[].SubnetId --output text) &> $TMP-1100
aws ec2 create-security-group --group-name gsp-kibana-${space} \
--vpc-id $vpcid --description "${gstype}-kibana-${space}" --region us-east-1 &> $TMP-1110
securitygroupid=$( \
aws ec2 describe-security-groups \
--filter Name=group-name,Values=gsp-kibana-${space} \
--region us-east-1 --query SecurityGroups[].GroupId --output text) &> $TMP-1120
else
vpcid=$( \
aws ec2 describe-vpcs --filter Name=tag:Name,Values="gsn-vpc" \
--region us-east-1 --query Vpcs[].VpcId --output text) &> $TMP-1200
subnetid=$( \
aws ec2 describe-subnets --filters Name=tag:Name,"Values=gsn-vpc: public A" \
--region us-east-1 --query Subnets[].SubnetId --output text) &> $TMP-1210
aws ec2 create-security-group --group-name gsn-kibana-${space} \
--vpc-id $vpcid --description "${gstype}-kibana-${space}" --region us-east-1 &> $TMP-1220
securitygroupid=$(aws ec2 describe-security-groups \
--filter Name=group-name,Values=gsn-kibana-${space} \
--region us-east-1 --query SecurityGroups[].GroupId --output text) &> $TMP-1300
fi
echo vpcid is ${vpcid}
echo subnetid is ${subnetid}
echo securitygroupid is ${securitygroupid}
aws ec2 authorize-security-group-ingress --group-id ${securitygroupid} \
--protocol tcp --port 443 --cidr 0.0.0.0/0 \
--region us-east-1 &> $TMP-1800
imageid=ami-b73b63a0 &> $TMP-1950 #Amazon Linux us-east-1
echo imageid is $imageid
##
# Create the stack via CloudFormation.
#
# Note:
# 1. This repo's name is hardcoded into the template's userdata area.
##
aws cloudformation create-stack --stack-name $stack \
--template-url \
https://s3.amazonaws.com/venicegeo-devops-dev-kibana-project/cf-kibana.json \
--region us-east-1 \
--parameters ParameterKey=instanceType,ParameterValue=t2.medium \
ParameterKey=subnetId,ParameterValue=${subnetid} \
ParameterKey=securityGroupId,ParameterValue=${securitygroupid} \
ParameterKey=guiPassword,ParameterValue=${guipassword} \
ParameterKey=space,ParameterValue=${space} &> $TMP-2000