-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf_micro.yaml
258 lines (256 loc) · 6.97 KB
/
cf_micro.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
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
AWSTemplateFormatVersion: 2010-09-09
Description: Live System Log Analysis and Visualization CSC 591 DIC
Parameters:
InstanceType:
Description: EC2 instance type
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
ConstraintDescription: EC2 instance tupe must be a supported.
KeyName:
Description: >-
(Optional) Name of an existing EC2 KeyPair to enable SSH access to the
instance. If this is not provided you will not be able to SSH on to the
EC2 instance.
Type: String
Default: 'live_log'
MinLength: '0'
MaxLength: '255'
AllowedPattern: '[\x20-\x7E]*'
ConstraintDescription: can contain only ASCII characters.
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.
Conditions:
UseEC2KeyName: !Not
- !Equals
- !Ref KeyName
- ''
Mappings:
AWSInstanceType2Arch:
t2.micro:
Arch: '64'
AWSRegionArch2AMI:
us-west-2:
'64': ami-0bbe6b35405ecebdb
Resources:
KinesisStream:
Type: 'AWS::Kinesis::Stream'
Properties:
ShardCount: '2'
KCLDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: leaseKey
AttributeType: S
KeySchema:
- AttributeName: leaseKey
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: '10'
WriteCapacityUnits: '5'
LogsDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: endpoint
AttributeType: S
- AttributeName: timestamp
AttributeType: S
KeySchema:
- AttributeName: endpoint
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: '10'
WriteCapacityUnits: '5'
Ec2SecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Enable SSH access and HTTP access on the inbound port
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: !Ref SSHLocation
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: 0.0.0.0/0
EIP:
Type: 'AWS::EC2::EIP'
Properties:
InstanceId: !Ref Ec2Instance
RootRole:
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: root
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: 'kinesis:*'
Resource: !Join
- ''
- - 'arn:aws:kinesis:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':stream/'
- !Ref KinesisStream
- Effect: Allow
Action: 'dynamodb:*'
Resource: !Join
- ''
- - 'arn:aws:dynamodb:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':table/'
- !Ref KCLDynamoDBTable
- Effect: Allow
Action: 'dynamodb:*'
Resource: !Join
- ''
- - 'arn:aws:dynamodb:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':table/'
- !Ref LogsDynamoDBTable
- Effect: Allow
Action: 'cloudwatch:*'
Resource: '*'
Roles:
- !Ref RootRole
RootInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: /
Roles:
- !Ref RootRole
Ec2Instance:
Type: 'AWS::EC2::Instance'
Metadata:
'AWS::CloudFormation::Init':
config:
packages:
yum:
python3: []
Properties:
KeyName: !If
- UseEC2KeyName
- !Ref KeyName
- !Ref 'AWS::NoValue'
ImageId: !FindInMap
- AWSRegionArch2AMI
- !Ref 'AWS::Region'
- !FindInMap
- AWSInstanceType2Arch
- !Ref InstanceType
- Arch
InstanceType: !Ref InstanceType
SecurityGroups:
- !Ref Ec2SecurityGroup
IamInstanceProfile: !Ref RootInstanceProfile
Ec2InstanceProducer:
Type: 'AWS::EC2::Instance'
Metadata:
'AWS::CloudFormation::Init':
config:
packages:
yum:
python3: []
Properties:
KeyName: !If
- UseEC2KeyName
- !Ref KeyName
- !Ref 'AWS::NoValue'
ImageId: !FindInMap
- AWSRegionArch2AMI
- !Ref 'AWS::Region'
- !FindInMap
- AWSInstanceType2Arch
- !Ref InstanceType
- Arch
InstanceType: !Ref InstanceType
SecurityGroups:
- !Ref Ec2SecurityGroup
IamInstanceProfile: !Ref RootInstanceProfile
Ec2InstanceConsumer:
Type: 'AWS::EC2::Instance'
Metadata:
'AWS::CloudFormation::Init':
config:
packages:
yum:
python3: []
Properties:
KeyName: !If
- UseEC2KeyName
- !Ref KeyName
- !Ref 'AWS::NoValue'
ImageId: !FindInMap
- AWSRegionArch2AMI
- !Ref 'AWS::Region'
- !FindInMap
- AWSInstanceType2Arch
- !Ref InstanceType
- Arch
InstanceType: !Ref InstanceType
SecurityGroups:
- !Ref Ec2SecurityGroup
IamInstanceProfile: !Ref RootInstanceProfile
Outputs:
URL:
Description: URL to the sample application's visualization
Value: !Join
- ''
- - 'http://'
- !GetAtt
- Ec2Instance
- PublicDnsName
InstanceId:
Description: InstanceId of the newly created EC2 instance
Value: !Ref Ec2Instance
AZ:
Description: Availability Zone of the newly created EC2 instance
Value: !GetAtt
- Ec2Instance
- AvailabilityZone
StreamName:
Description: >-
The name of the Kinesis Stream. This was autogenerated by the Kinesis
Resource named 'KinesisStream'
Value: !Ref KinesisStream
ApplicationName:
Description: >-
The name of the Kinesis Client Application. This was autogenerated by the
DynamoDB Resource named 'KCLDynamoDBTable'
Value: !Ref KCLDynamoDBTable
CountsTable:
Description: >-
The name of the DynamoDB table where counts are persisted. This was
autogenerated by the DynamoDB Resource named 'CountsDynamoDBTable'
Value: !Ref LogsDynamoDBTable