-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate.yaml
157 lines (157 loc) · 4.25 KB
/
template.yaml
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
AWSTemplateFormatVersion: 2010-09-09
Description: A 3-node Hadoop cluster and its associated security groups
Parameters:
VPNPublicIP:
Description: Public IP of VPN used to connect to Web UI
Type: String
Default: 0.0.0.0/0 # All
VPCCidr:
Description: IPv4 CIDR of AWS VPC
Type: String
KeyName:
Description: EC2 key-pair to SSH on instance
Type: AWS::EC2::KeyPair::KeyName
MasterInstanceType:
Description: EC2 instance type for Master node
Type: String
Default: t3.medium
SlaveInstanceType:
Description: EC2 instance type for Slave nodes
Type: String
Default: t3.medium
BaseImage:
Description: Image ID for creating instance
Type: String
Default: ami-08d658f84a6d84a80 # Ubuntu Server 18.04 LTS x86_64
Resources:
MasterNode:
Type: AWS::EC2::Instance
Properties:
KeyName: !Ref KeyName
InstanceType:
Ref: MasterInstanceType
ImageId:
Ref: BaseImage
SecurityGroups:
- !Ref MasterSecurityGroup
- !Ref SSHSecurityGroup
Tags:
-
Key: Name
Value: Hadoop-Master
SlaveNode1:
Type: AWS::EC2::Instance
Properties:
KeyName: !Ref KeyName
InstanceType:
Ref: SlaveInstanceType
ImageId:
Ref: BaseImage
SecurityGroups:
- !Ref SlaveSecurityGroup
- !Ref SSHSecurityGroup
Tags:
-
Key: Name
Value: Hadoop-Slave-1
SlaveNode2:
Type: AWS::EC2::Instance
Properties:
KeyName: !Ref KeyName
InstanceType:
Ref: SlaveInstanceType
ImageId:
Ref: BaseImage
SecurityGroups:
- !Ref SlaveSecurityGroup
- !Ref SSHSecurityGroup
Tags:
-
Key: Name
Value: Hadoop-Slave-2
SSHSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: SSH
GroupDescription: Enable SSH access
SecurityGroupIngress:
- CidrIp: !ref VPNPublicIp
IpProtocol: tcp
FromPort: 22
ToPort: 22
MasterSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: hadoop-master
GroupDescription: Configure ports to allow basic Hadoop usage.
SecurityGroupIngress:
- CidrIp: !ref VPNPublicIp
IpProtocol: tcp
Description: Web UI for HDFS Name node
FromPort: 9870
ToPort: 9870
- CidrIp: !ref VPCCidr
IpProtocol: tcp
Description: Metadata operations
FromPort: 9000
ToPort: 9000
- CidrIp: !ref VPCCidr
IpProtocol: tcp
Description: Name Node backup
FromPort: 9868
ToPort: 9868
SlaveSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: hadoop-slave
GroupDescription: Configure ports to allow basic Hadoop usage.
SecurityGroupIngress:
- CidrIp: !ref VPNPublicIp
IpProtocol: tcp
Description: Web UI for HDFS Data node
FromPort: 9864
ToPort: 9864
- CidrIp: !ref VPCCidr
IpProtocol: tcp
Description: Data Transfer between slave nodes
FromPort: 9866
ToPort: 9866
- CidrIp: !ref VPCCidr
IpProtocol: tcp
Description: Metadata operations
FromPort: 9867
ToPort: 9867
MasterNodeIPAddress:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
MasterNodeIPAssoc:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: !Ref MasterNode
EIP: !Ref MasterNodeIPAddress
SlaveNode1IPAddress:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
SlaveNode1IPAssoc:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: !Ref SlaveNode1
EIP: !Ref SlaveNode1IPAddress
SlaveNode2IPAddress:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
SlaveNode2IPAssoc:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: !Ref SlaveNode2
EIP: !Ref SlaveNode2IPAddress
Outputs:
MasterNodeInstanceId:
Description: InstanceId of the MasterNode EC2 instance
Value: !Ref MasterNode
MasterNodeInstanceIPAddress:
Description: IP address of the MasterNode EC2 instance
Value: !Ref MasterNodeIPAddress