This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 628
/
zeppelin-yarn-on-ec2.json
355 lines (337 loc) · 15.3 KB
/
zeppelin-yarn-on-ec2.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Template: Zeppelin_Yarn_Client: Create a Zeppelin EC2 instance. This template demonstrates using the AWS CloudFormation bootstrap scripts to install Maven, Git, Apache Spark and Apache Zeppelin at instance launch time. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "Can contain only ASCII characters."
},
"InstanceType" : {
"Description" : "Zeppelin EC2 instance type",
"Type" : "String",
"Default" : "m3.xlarge",
"AllowedValues" : [ "t2.small", "t2.medium", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "g2.2xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"],
"ConstraintDescription" : "Must be a valid EC2 instance type"
},
"EMRMasterSecurityGroup": {
"Description" : "Name of an existing EMR Master Security Group",
"Type": "AWS::EC2::SecurityGroup::Id",
"ConstraintDescription" : "Can contain only ASCII characters."
},
"EMRSlaveSecurityGroup": {
"Description" : "Name of an existing EMR Master Security Group",
"Type": "AWS::EC2::SecurityGroup::Id",
"ConstraintDescription" : "Can contain only ASCII characters."
},
"S3HadoopConfFolder": {
"Description" : "S3 bucket and folder which contains your hadoop conf directory",
"Type": "String",
"Default":"mybucket/hadoopconf"
},
"S3HiveConfFolder": {
"Description" : "S3 bucket and folder which contains your hive conf directory",
"Type": "String",
"Default":"mybucket/hiveconf"
},
"ZeppelinSubnetId": {
"Description" : "Choose a subnet to launch your Zeppelin Instance",
"Type": "AWS::EC2::Subnet::Id"
},
"ZeppelinVPCId": {
"Description" : "Choose a VPC to launch your Zeppelin Instance",
"Type": "AWS::EC2::VPC::Id"
},
"ZeppelinAccessLocation" : {
"Description" : "The IP address range that can be used to access Zeppelin on port 8080",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "Must be a valid IP CIDR range of the form x.x.x.x/x"
},
"SSHLocation" : {
"Description" : "The IP address range that can be used to SSH to the EC2 instances",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "Must be a valid IP CIDR range of the form x.x.x.x/x"
}
},
"Mappings" : {
"AWSInstanceType2Arch" : {
"t2.small" : { "Arch" : "HVM64" },
"t2.medium" : { "Arch" : "HVM64" },
"m1.small" : { "Arch" : "PV64" },
"m1.medium" : { "Arch" : "PV64" },
"m1.large" : { "Arch" : "PV64" },
"m1.xlarge" : { "Arch" : "PV64" },
"m2.xlarge" : { "Arch" : "PV64" },
"m2.2xlarge" : { "Arch" : "PV64" },
"m2.4xlarge" : { "Arch" : "PV64" },
"m3.medium" : { "Arch" : "HVM64" },
"m3.large" : { "Arch" : "HVM64" },
"m3.xlarge" : { "Arch" : "HVM64" },
"m3.2xlarge" : { "Arch" : "HVM64" },
"c1.medium" : { "Arch" : "PV64" },
"c1.xlarge" : { "Arch" : "PV64" },
"c3.large" : { "Arch" : "HVM64" },
"c3.xlarge" : { "Arch" : "HVM64" },
"c3.2xlarge" : { "Arch" : "HVM64" },
"c3.4xlarge" : { "Arch" : "HVM64" },
"c3.8xlarge" : { "Arch" : "HVM64" },
"g2.2xlarge" : { "Arch" : "HVMG2" },
"r3.large" : { "Arch" : "HVM64" },
"r3.xlarge" : { "Arch" : "HVM64" },
"r3.2xlarge" : { "Arch" : "HVM64" },
"r3.4xlarge" : { "Arch" : "HVM64" },
"r3.8xlarge" : { "Arch" : "HVM64" },
"i2.xlarge" : { "Arch" : "HVM64" },
"i2.2xlarge" : { "Arch" : "HVM64" },
"i2.4xlarge" : { "Arch" : "HVM64" },
"i2.8xlarge" : { "Arch" : "HVM64" },
"hi1.4xlarge" : { "Arch" : "HVM64" },
"hs1.8xlarge" : { "Arch" : "HVM64" },
"cr1.8xlarge" : { "Arch" : "HVM64" },
"cc2.8xlarge" : { "Arch" : "HVM64" }
},
"AWSRegionArch2AMI" : {
"us-east-1" : { "PV64" : "ami-50842d38", "HVM64" : "ami-08842d60", "HVMG2" : "ami-3a329952" },
"us-west-2" : { "PV64" : "ami-af86c69f", "HVM64" : "ami-8786c6b7", "HVMG2" : "ami-47296a77" },
"us-west-1" : { "PV64" : "ami-c7a8a182", "HVM64" : "ami-cfa8a18a", "HVMG2" : "ami-331b1376" },
"eu-west-1" : { "PV64" : "ami-aa8f28dd", "HVM64" : "ami-748e2903", "HVMG2" : "ami-00913777" },
"ap-southeast-1" : { "PV64" : "ami-20e1c572", "HVM64" : "ami-d6e1c584", "HVMG2" : "ami-fabe9aa8" },
"ap-northeast-1" : { "PV64" : "ami-21072820", "HVM64" : "ami-35072834", "HVMG2" : "ami-5dd1ff5c" },
"ap-southeast-2" : { "PV64" : "ami-8b4724b1", "HVM64" : "ami-fd4724c7", "HVMG2" : "ami-e98ae9d3" },
"sa-east-1" : { "PV64" : "ami-9d6cc680", "HVM64" : "ami-956cc688", "HVMG2" : "NOT_SUPPORTED" },
"cn-north-1" : { "PV64" : "ami-a857c591", "HVM64" : "ami-ac57c595", "HVMG2" : "NOT_SUPPORTED" },
"eu-central-1" : { "PV64" : "ami-a03503bd", "HVM64" : "ami-b43503a9", "HVMG2" : "ami-b03503ad" }
}
},
"Resources" : {
"ZeppelinInstance": {
"Type": "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Interface" : {
"ParameterGroups" : [
{
"Label" : { "default" : "Network Configuration" },
"Parameters" : [ "ZeppelinVPCID", "ZeppelinSubnetId", "EMRMasterSecurityGroup", "EMRMasterSlaveGroup" ]
},
{
"Label" : { "default":"Amazon EC2 Configuration" },
"Parameters" : [ "InstanceType", "KeyName" ]
}
],
"ParameterLabels" : {
"ZeppelinVPCID" : { "default" : "Which VPC should this be deployed to?" }
}
},
"AWS::CloudFormation::Init" : {
"configSets" : {
"InstallAndRun" : [ "Install", "Configure" ]
},
"Install" : {
"packages" : {
"yum" : {
"git" : [],
"java-1.7.0-openjdk-devel.x86_64": []
}
},
"sources": {
"/home/ec2-user/prereqs/": "http://aws-bigdata-blog.s3.amazonaws.com/artifacts/spark-1.5.2-bin-hadoop2.6.tgz"
},
"commands" : {
"01-install-git" : {
"command" : "git clone https://github.com/apache/incubator-zeppelin /home/ec2-user/zeppelin",
"ignoreErrors" : "true"
},
"02-maven-step1": {
"command" : "wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo",
"ignoreErrors" : "true"
},
"03-maven-step2": {
"command" : "sed -i s/\\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo",
"ignoreErrors" : "true"
},
"04-download_hadoopconf" : {
"command" : { "Fn::Join" : ["", ["aws s3 sync s3://", { "Ref" : "S3HadoopConfFolder" }, " ", "/home/ec2-user/hadoopconf"]]},
"ignoreErrors" : "true"
},
"05-download_hive-site.xml" : {
"command" : { "Fn::Join" : ["", ["aws s3 cp s3://", { "Ref" : "S3HiveConfFolder" },"/hive-site.xml", " ", "/home/ec2-user/zeppelin/conf/hive-site.xml"]]},
"ignoreErrors" : "true"
}
},
"files" : {
"/etc/cfn/cfn-hup.conf" : {
"content" : { "Fn::Join" : ["", [
"[main]\n",
"stack=", { "Ref" : "AWS::StackId" }, "\n",
"region=", { "Ref" : "AWS::Region" }, "\n"
]]},
"mode" : "000400",
"owner" : "root",
"group" : "root"
},
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" : {
"content": { "Fn::Join" : ["", [
"[cfn-auto-reloader-hook]\n",
"triggers=post.update\n",
"path=Resources.ZeppelinInstance.Metadata.AWS::CloudFormation::Init\n",
"action=/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource ZeppelinInstance ",
" --configsets InstallAndRun ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"runas=root\n"
]]}
}
},
"services" : {
"sysvinit" : {
"cfn-hup" : { "enabled" : "true", "ensureRunning" : "true",
"files" : ["/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-reloader.conf"]}
}
}
},
"Configure" : {
"packages" : {
"yum" : {
"apache-maven" : []
}
},
"files" : {
"/home/ec2-user/prereqs/spark-1.5.2-bin-hadoop2.6/conf/spark-env.sh": {
"source" : "https://raw.githubusercontent.com/awslabs/aws-big-data-blog/master/aws-blog-zeppelin-yarn-on-ec2/conf/spark-env.sh",
"mode": "000644",
"owner" : "root",
"group" : "root"
},
"/home/ec2-user/zeppelin/conf/zeppelin-env.sh": {
"source" : "https://raw.githubusercontent.com/awslabs/aws-big-data-blog/master/aws-blog-zeppelin-yarn-on-ec2/conf/zeppelin-env.sh",
"mode": "000644",
"owner" : "root",
"group" : "root"
},
"/home/ec2-user/zeppelin/conf/zeppelin-site.xml": {
"source" : "https://raw.githubusercontent.com/awslabs/aws-big-data-blog/master/aws-blog-zeppelin-yarn-on-ec2/conf/zeppelin-site.xml",
"mode": "000644",
"owner" : "root",
"group" : "root"
}
},
"commands" : {
"01_change_owner_zeppelin" : {
"command" : "chown -R ec2-user /home/ec2-user/zeppelin",
"ignoreErrors" : "true"
},
"02_build_zeppelin" : {
"command" : "cd /home/ec2-user/zeppelin; mvn clean package -Pspark-1.5 -Dspark.version=1.5.2 -Phadoop-2.6 -Pyarn -DskipTests",
"ignoreErrors" : "true"
}
}
}
}
},
"Properties": {
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
"InstanceType" : { "Ref" : "InstanceType" },
"KeyName" : { "Ref" : "KeyName" },
"NetworkInterfaces" : [{
"GroupSet" : [{ "Ref" : "ZeppelinSecurityGroup" }],
"AssociatePublicIpAddress" : "true",
"DeviceIndex" : "0",
"DeleteOnTermination" : "true",
"SubnetId" : { "Ref" : "ZeppelinSubnetId" }
}],
"IamInstanceProfile": {
"Ref": "MyInstanceProfile"
},
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe\n",
"yum update -y aws-cfn-bootstrap\n",
"echo 'export JAVA_HOME=/etc/alternatives/java_sdk' >> /home/ec2-user/.bash_profile\n",
"echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /home/ec2-user/.bash_profile\n",
"# Install the files and packages from the metadata\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource ZeppelinInstance ",
" --configsets InstallAndRun ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"# Signal the status from cfn-init\n",
"/opt/aws/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource ZeppelinInstance ",
" --region ", { "Ref" : "AWS::Region" }, "\n"
]]}}
},
"CreationPolicy" : {
"ResourceSignal" : {
"Timeout" : "PT30M"
}
}
},
"MyRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version" : "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Principal": {
"Service": [ "ec2.amazonaws.com" ]
},
"Action": [ "sts:AssumeRole" ]
} ]
},
"Path": "/"
}
},
"RolePolicies": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "s3access",
"PolicyDocument": {
"Version" : "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
} ]
},
"Roles": [ { "Ref": "MyRole" } ]
}
},
"MyInstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [ { "Ref": "MyRole" } ]
}
},
"ZeppelinSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable access to Zeppelin over port 8080, access to EMR cluster through EMRMaster and EMRSlave Security Groups",
"VpcId" : { "Ref" : "ZeppelinVPCId" },
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "8080", "ToPort" : "8080", "CidrIp" : { "Ref" : "ZeppelinAccessLocation"}},
{"IpProtocol" : "tcp", "FromPort" : "0", "ToPort" : "65535", "SourceSecurityGroupId" : { "Ref" : "EMRMasterSecurityGroup"}},
{"IpProtocol" : "tcp", "FromPort" : "0", "ToPort" : "65535", "SourceSecurityGroupId" : { "Ref" : "EMRSlaveSecurityGroup"}},
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : { "Ref" : "SSHLocation"}}
]
}
}
},
"Outputs" : {
"WebsiteURL" : {
"Description" : "URL for newly created Zeppelin stack",
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "ZeppelinInstance", "PublicDnsName"]},":8080"]] }
}
}
}