-
Notifications
You must be signed in to change notification settings - Fork 3
/
cassandra.template
185 lines (163 loc) · 6.39 KB
/
cassandra.template
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
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation template to spin up a Cassandra Seed node on Ubuntu 11.10",
"Parameters" : {
"KeyName" : {
"Default" : "drupal-demo-keypair",
"Description" : "Name of an existing EC2 SSH KeyPair",
"Type" : "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern" : "[-_ a-zA-Z0-9]*",
"ConstraintDescription" : "can contain only alphanumeric characters, spaces, dashes and underscores."
},
"InstanceType" : {
"Description" : "WebServer EC2 instance type",
"Type" : "String",
"Default" : "c1.medium",
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge"],
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"AvailabilityZone" : {
"Default" : "us-east-1b",
"Description" : "Name of availability zone", "Type" : "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedValues" : ["us-east-1a", "us-east-1b","us-east-1c","us-east-1d","us-east-1e",
"us-west-1a", "us-west-1b", "us-west-1c",
"us-west-2a", "us-west-2b",
"eu-west-1a", "eu-west-1b", "eu-west-1c",
"ap-southeast-1a", "ap-southeast-1b",
"ap-northeast-1a", "ap-northeast-1b",
"sa-east-1a", "sa-east-1b"
],
"ConstraintDescription" : "must be a valid availability zone."
},
"SecurityGroupIds" : {
"Default" : "cassandra",
"Description" : "Name of security group", "Type" : "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern" : "[-_ a-zA-Z0-9]*",
"ConstraintDescription" : "can contain only alphanumeric characters, spaces, dashes and underscores."
}
},
"Mappings" : {
"AWSInstanceType2Arch" : {
"t1.micro" : { "Arch" : "64" },
"m1.small" : { "Arch" : "64" },
"m1.medium" : { "Arch" : "64" },
"m1.large" : { "Arch" : "64" },
"m1.xlarge" : { "Arch" : "64" },
"m2.xlarge" : { "Arch" : "64" },
"m2.2xlarge" : { "Arch" : "64" },
"m2.4xlarge" : { "Arch" : "64" },
"c1.medium" : { "Arch" : "64" },
"c1.xlarge" : { "Arch" : "64" }
},
"AWSRegionArch2AMI" : {
"us-east-1" : { "64" : "ami-baba68d3" },
"us-west-1" : { "64" : "ami-6da8f128" },
"us-west-2" : { "64" : "ami-ae05889e" },
"eu-west-1" : { "64" : "ami-895069fd" },
"ap-southeast-1" : { "64" : "ami-4296d210" },
"ap-northeast-1" : { "64" : "ami-10299f11" },
"sa-east-1" : { "64" : "ami-b673acab" }
}
},
"Resources" : {
"CfnUser" : {
"Type" : "AWS::IAM::User",
"Properties" : {
"Path": "/",
"Policies": [{
"PolicyName": "root",
"PolicyDocument": { "Statement":[{
"Effect":"Allow",
"Action":"cloudformation:DescribeStackResource",
"Resource":"*"
}]}
}]
}
},
"HostKeys" : {
"Type" : "AWS::IAM::AccessKey",
"Properties" : {
"UserName" : {"Ref": "CfnUser"}
}
},
"CassandraSeedServer": {
"Type": "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"files" : {
"/etc/apt/sources.list.d/cassandra.list" : {
"content" : { "Fn::Join" : ["", [
"deb http://www.apache.org/dist/cassandra/debian 10x main\n",
"deb-src http://www.apache.org/dist/cassandra/debian 10x main"
]]},
"mode" : "000644",
"owner" : "root",
"group" : "root"
}
}
}
}
},
"Properties" : {
"ImageId" : {
"Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
"InstanceType" : { "Ref" : "InstanceType" },
"KeyName" : { "Ref" : "KeyName" },
"AvailabilityZone" : { "Ref" : "AvailabilityZone" },
"SecurityGroupIds" : [ { "Ref" : "SecurityGroupIds" } ],
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"function error_exit\n",
"{\n",
" cfn-signal -e 1 -r \"$1\" '", { "Ref" : "CassandraSeedServerWaitHandle" }, "'\n",
" exit 1\n",
"}\n",
"apt-get -y install python-setuptools\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-1.0-6.tar.gz\n",
"cfn-init --region ", { "Ref" : "AWS::Region" },
" -s ", { "Ref" : "AWS::StackName" }, " -r CassandraSeedServer ",
" --access-key ", { "Ref" : "HostKeys" },
" --secret-key ", {"Fn::GetAtt": ["HostKeys", "SecretAccessKey"]}, " || error_exit 'Failed to run cfn-init'\n",
"apt-get -y update\n",
"apt-get -y dist-upgrade\n",
"gpg --keyserver pgp.mit.edu --recv-keys F758CE318D77295D\n",
"gpg --export --armor F758CE318D77295D | sudo apt-key add -\n",
"gpg --keyserver pgp.mit.edu --recv-keys 2B5C1B00\n",
"gpg --export --armor 2B5C1B00 | sudo apt-key add -\n",
"apt-get -y update\n",
"apt-get -y install cassandra\n",
"#/etc/init.d/cassandra stop\n",
"#rm /var/lib/cassandra/commitlog/*\n",
"#rm -r /var/lib/cassandra/data/\n",
"# If all went well, signal success\n",
"cfn-signal -e $? -r 'Cassandra Seed Server configuration' '", { "Ref" : "CassandraSeedServerWaitHandle" }, "'\n"
]]}}
}
},
"CassandraSeedServerWaitHandle" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle"
},
"CassandraSeedServerWaitCondition" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn" : "CassandraSeedServer",
"Properties" : {
"Handle" : { "Ref" : "CassandraSeedServerWaitHandle" },
"Timeout" : "1200"
}
}
},
"Outputs" : {
"PublicDNSName" : {
"Description" : "Cassandra seed server",
"Value" : { "Fn::GetAtt" : [ "CassandraSeedServer", "PublicDnsName" ] }
}
}
}