forked from aerospike/aws-cloudformation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aerospike-cf-hvm.json
229 lines (210 loc) · 7.53 KB
/
aerospike-cf-hvm.json
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Template to create an Aerospike cluster",
"Parameters" : {
"KeyPair" : {
"Description" : "Name of the KeyPair that would be used to ssh into the instances",
"Type" : "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "Please specify the name of the keypair that you use to login"
},
"NumberOfInstances" : {
"Description" : "Number of instances in the cluster",
"Type" : "Number",
"Default" : "4"
},
"InstanceType" : {
"Description" : "Type of EC2 instance to launch. Choose the one which allows HVM AMIs",
"Type" : "String",
"Default" : "r3.2xlarge",
"AllowedValues" : [ "t2.micro", "t2.small", "t2.medium",
"m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge",
"c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge",
"r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge"
],
"ConstraintDescription" : "Use an instance type which supports linux HVM AMI"
}
},
"Mappings" : {
"AWSRegionalAMIs" : {
"us-east-1" : {"name": "Northern Virginia", "hvm" : "ami-71b1371a" },
"us-west-2" : {"name": "Oregon", "hvm" : "ami-3f4c5f0f" },
"us-west-1" : {"name": "Northern California", "hvm" : "ami-d139c295" },
"eu-west-1" : {"name": "Ireland", "hvm" : "ami-8dfcd8fa" },
"eu-central-1" : {"name" : "Franfurt", "hvm" : "ami-d61d1ccb" },
"ap-southeast-1" : {"name": "Singapore", "hvm" : "ami-dc1b108e" },
"ap-southeast-2" : {"name": "Sydney", "hvm" : "ami-8b3579b1" },
"ap-northeast-1" : {"name": "Tokyo", "hvm" : "ami-56f17e56" },
"sa-east-1" : {"name": "Sao Paulo", "hvm" : "ami-b9f57fa4" }
}
},
"Resources" : {
"ClusterRole" : {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version" : "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Principal": {
"Service": [ "ec2.amazonaws.com" ]
},
"Action": [ "sts:AssumeRole" ]
} ]
},
"Path": "/",
"Policies": [ {
"PolicyName": "AerospikeClusterRole",
"PolicyDocument": {
"Version" : "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Action": "ec2:DescribeInstances",
"Resource": "*"
} ]
}
} ]
}
},
"ClusterInstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [ {
"Ref": "ClusterRole"
} ]
}
},
"ClusterGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"DependsOn" : "GatewayToInternet",
"Properties" : {
"LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
"DesiredCapacity" : { "Ref" : "NumberOfInstances"},
"MinSize" : "1",
"MaxSize" : "15",
"AvailabilityZones" : [ { "Fn::Select" : [ "0", { "Fn::GetAZs" : { "Ref" : "AWS::Region" } } ] } ],
"VPCZoneIdentifier" : [{ "Ref" : "PublicSubnet" }],
"Tags" : [ {"Key" : "StackID", "Value" : { "Ref" : "AWS::StackId"}, "PropagateAtLaunch" : "true" } ]
}
},
"LaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"DependsOn" : "GatewayToInternet",
"Properties" : {
"InstanceType" : { "Ref" : "InstanceType"},
"KeyName" : { "Ref" : "KeyPair" },
"IamInstanceProfile" : { "Ref" : "ClusterInstanceProfile" },
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionalAMIs", { "Ref": "AWS::Region" }, "hvm" ] },
"AssociatePublicIpAddress" : "true",
"SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"echo ClusterInstancesScriptStart > /var/log/awsuserdatascript\n",
" ###Point to the first instance using the mesh-address config option\n",
" PRIVATEIP=$(aws ec2 describe-instances --filter Name=tag-key,Values=StackID Name=tag-value,Values=", { "Ref" : "AWS::StackId" }," --output=text --region=",{ "Ref" : "AWS::Region" }," | grep PRIVATEIPADDRESSES | awk '{print $4}') \n",
" echo $PRIVATEIP >> /var/log/awsuserdatascript\n",
" sed -i '/.*mesh-seed-address-port/d' /etc/aerospike/aerospike.conf\n",
" for i in $PRIVATEIP; do ",
" sed -i \"/interval/i \t\tmesh-seed-address-port $i 3002\" /etc/aerospike/aerospike.conf\n",
" done \n",
" /etc/init.d/aerospike start\n",
" /etc/init.d/amc start\n",
"echo OtherInstancesScriptFinish >> /var/log/awsuserdatascript\n"
] ] }
}
}
},
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : "10.0.0.0/16",
"EnableDnsSupport" : "true",
"EnableDnsHostnames" : "true",
"Tags" : [ {"Key" : "StackID", "Value" : { "Ref" : "AWS::StackId"} } ]
}
},
"PublicSubnet" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"CidrBlock" : "10.0.0.0/24",
"AvailabilityZone" : { "Fn::Select" : [ "0", { "Fn::GetAZs" : { "Ref" : "AWS::Region" } } ] },
"Tags" : [ {"Key" : "StackID", "Value" : { "Ref" : "AWS::StackId"} } ]
}
},
"InternetGateway" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [ {"Key" : "StackID", "Value" : { "Ref" : "AWS::StackId"} } ]
}
},
"GatewayToInternet" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"InternetGatewayId" : { "Ref" : "InternetGateway" }
}
},
"PublicRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"Tags" : [ {"Key" : "StackID", "Value" : { "Ref" : "AWS::StackId"} } ]
}
},
"PublicRoute" : {
"Type" : "AWS::EC2::Route",
"DependsOn" : "GatewayToInternet",
"Properties" : {
"RouteTableId" : { "Ref" : "PublicRouteTable" },
"DestinationCidrBlock" : "0.0.0.0/0",
"GatewayId" : { "Ref" : "InternetGateway" }
}
},
"PublicSubnetRouteTableAssociation" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "PublicSubnet" },
"RouteTableId" : { "Ref" : "PublicRouteTable" }
}
},
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable ports needed by SSH and Aerospike and XDR",
"VpcId" : { "Ref" : "VPC" },
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : "0.0.0.0/0"
},
{
"IpProtocol" : "tcp",
"FromPort" : "3000",
"ToPort" : "3000",
"CidrIp" : "0.0.0.0/0"
},
{
"IpProtocol" : "tcp",
"FromPort" : "3001",
"ToPort" : "3004",
"CidrIp" : "10.0.0.0/16"
},
{
"IpProtocol" : "tcp",
"FromPort" : "8081",
"ToPort" : "8081",
"CidrIp" : "0.0.0.0/0"
},
{
"IpProtocol" : "icmp",
"FromPort" : "-1",
"ToPort" : "-1",
"CidrIp" : "0.0.0.0/0"
} ],
"Tags" : [ {"Key" : "StackID", "Value" : { "Ref" : "AWS::StackId"} } ]
}
}
}
}