This repository was archived by the owner on Jun 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCognitoStreamsSample.json
538 lines (538 loc) · 15 KB
/
CognitoStreamsSample.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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Amazon Cognito Streams Sample",
"Parameters": {
"StreamName": {
"Type": "String",
"MinLength": "1",
"MaxLength": "128",
"Description": "Enter the kinesis stream that you associated with your identity pool.",
"ConstraintDescription": "Enter in a valid string"
},
"InboundTraffic": {
"Description": "Allow inbound traffic to the cluster from this CIDR range.",
"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 CIDR range of the form x.x.x.x/x."
},
"PortNumber": {
"Description": "The port number on which the cluster accepts incoming connections.",
"Type": "Number",
"Default": "5439"
},
"MasterUserName": {
"Description": "The username that is associated with the master user account for the cluster that is being created",
"MinLength": "1",
"MaxLength": "127",
"Type": "String"
},
"MasterUserPassword": {
"Description": "The password that is associated with the master user account for the cluster that is being created (min 8 characters, contain at least one uppercase letter, one lowercase letter, and one number).",
"Type": "String",
"MinLength": "8",
"MaxLength": "64",
"ConstraintDescription": "Must meet Redshift password requirements (min 8 characters, contain at least one uppercase letter, one lowercase letter, and one number).",
"NoEcho": "true"
},
"AlarmEmail": {
"Description": "Email address to notify if there are any operational issues",
"Type": "String",
"AllowedPattern": "([a-zA-Z0-9_.-]+)@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,4}",
"ConstraintDescription": "must be a valid email address."
},
"Delay": {
"Type": "Number",
"Description": "Enter the delay (in milliseconds) in consumption from stream after which alarm will be triggered.",
"Default": "3600000"
},
"KinesisRecordThreshold": {
"Type": "Number",
"Description": "Enter the incoming records in 5 mins in Kinesis after that you will be notified to provision more shards. Each shard can support up to 1000 records written per second.",
"Default": "240000"
}
},
"Resources": {
"AmazonCognitoStreamsSampleRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "AmazonCognitoStreamsSamplePolicy",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"dynamodb:*",
"s3:*",
"cloudwatch:*",
"kinesis:*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
}
]
}
},
"AmazonCognitoStreamsSampleInstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [
{
"Ref": "AmazonCognitoStreamsSampleRole"
}
]
}
},
"AmazonCognitoStreamsSampleApplication": {
"Type": "AWS::ElasticBeanstalk::Application",
"Properties": {
"Description": "Sample application for showcasing Amazon Cognito streams",
"ApplicationVersions": [
{
"VersionLabel": "Version1",
"Description": "Release version",
"SourceBundle": {
"S3Bucket": { "Fn::Join": ["-", [ "amazon-cognito-samples", { "Ref": "AWS::Region" } ] ] },
"S3Key": "AmazonCognitoStreamsSample-1.0.war"
}
}
],
"ConfigurationTemplates": [
{
"TemplateName": "DefaultConfiguration",
"Description": "64bit Amazon Linux running Tomcat 7",
"SolutionStackName": "64bit Amazon Linux 2014.09 v1.1.0 running Tomcat 7 Java 7",
"OptionSettings": [
{
"Namespace": "aws:elasticbeanstalk:environment",
"OptionName": "EnvironmentType",
"Value": "SingleInstance"
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "InstanceType",
"Value": "t2.micro"
},
{
"Namespace": "aws:autoscaling:asg",
"OptionName": "MaxSize",
"Value": "1"
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "IamInstanceProfile",
"Value": {
"Ref": "AmazonCognitoStreamsSampleInstanceProfile"
}
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "VPCId",
"Value": { "Ref": "VPC" }
},
{
"Namespace": "aws:ec2:vpc",
"OptionName": "Subnets",
"Value": { "Ref" : "PublicSubnet" }
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "JDBC_CONNECTION_STRING",
"Value": {
"Fn::Join": [
"",
[
"jdbc:postgresql://",
{
"Fn::GetAtt": [
"RedshiftCluster",
"Endpoint.Address"
]
},
":",
{
"Fn::GetAtt": [
"RedshiftCluster",
"Endpoint.Port"
]
},
"/cognito?tcpKeepAlive=true"
]
]
}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "PARAM1",
"Value": {
"Ref": "StreamName"
}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "PARAM2",
"Value": {
"Ref": "MasterUserName"
}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "PARAM3",
"Value": {
"Ref": "MasterUserPassword"
}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "PARAM4",
"Value": {
"Ref": "S3IntermediateBucket"
}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "PARAM5",
"Value": {
"Ref": "AWS::Region"
}
}
]
}
]
}
},
"AmazonCognitoStreamsSampleEnvironment": {
"Type": "AWS::ElasticBeanstalk::Environment",
"Properties": {
"ApplicationName": {
"Ref": "AmazonCognitoStreamsSampleApplication"
},
"Description": "AmazonCognitoStreamsSampleEnvironment",
"TemplateName": "DefaultConfiguration",
"VersionLabel": "Version1"
}
},
"S3IntermediateBucket": {
"Type": "AWS::S3::Bucket",
"DeletionPolicy": "Retain",
"Properties": {
"LifecycleConfiguration": {
"Rules": [
{
"ExpirationInDays": "10",
"Id": "delete-old-files",
"Status": "Enabled"
}
]
}
}
},
"RedshiftCluster": {
"Type": "AWS::Redshift::Cluster",
"DependsOn": "AttachGateway",
"Properties": {
"DBName": "cognito",
"MasterUsername": {
"Ref": "MasterUserName"
},
"MasterUserPassword": {
"Ref": "MasterUserPassword"
},
"NodeType": "dw2.large",
"ClusterType": "single-node",
"ClusterParameterGroupName": {
"Ref": "RedshiftClusterParameterGroup"
},
"VpcSecurityGroupIds": [
{
"Ref": "SecurityGroup"
}
],
"ClusterSubnetGroupName": {
"Ref": "RedshiftClusterSubnetGroup"
},
"PubliclyAccessible": "true",
"Port": {
"Ref": "PortNumber"
}
}
},
"RedshiftClusterParameterGroup": {
"Type": "AWS::Redshift::ClusterParameterGroup",
"Properties": {
"Description": "Cluster parameter group",
"ParameterGroupFamily": "redshift-1.0",
"Parameters": [
{
"ParameterName": "enable_user_activity_logging",
"ParameterValue": "true"
}
]
}
},
"RedshiftClusterSubnetGroup": {
"Type": "AWS::Redshift::ClusterSubnetGroup",
"Properties": {
"Description": "Cluster subnet group",
"SubnetIds": [
{
"Ref": "PublicSubnet"
}
]
}
},
"VPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16"
}
},
"PublicSubnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.0.0.0/24",
"VpcId": {
"Ref": "VPC"
}
}
},
"SecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Security group",
"SecurityGroupIngress": [
{
"CidrIp": {
"Ref": "InboundTraffic"
},
"FromPort": {
"Ref": "PortNumber"
},
"ToPort": {
"Ref": "PortNumber"
},
"IpProtocol": "tcp"
}
],
"VpcId": {
"Ref": "VPC"
}
}
},
"myInternetGateway": {
"Type": "AWS::EC2::InternetGateway"
},
"AttachGateway": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"InternetGatewayId": {
"Ref": "myInternetGateway"
}
}
},
"PublicRouteTable": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "VPC"
}
}
},
"PublicRoute": {
"Type": "AWS::EC2::Route",
"DependsOn": "AttachGateway",
"Properties": {
"RouteTableId": {
"Ref": "PublicRouteTable"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "myInternetGateway"
}
}
},
"PublicSubnetRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "PublicSubnet"
},
"RouteTableId": {
"Ref": "PublicRouteTable"
}
}
},
"DynamoDBTable": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"AttributeDefinitions": [
{
"AttributeName": "leaseKey",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "leaseKey",
"KeyType": "HASH"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 10
},
"TableName": "AmazonCognitoStreamsSample"
}
},
"AlarmTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"Subscription": [
{
"Endpoint": {
"Ref": "AlarmEmail"
},
"Protocol": "email"
}
]
}
},
"KinesisIteratorAgeAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Alarm if Kinesis iterator age goes above 1 hour",
"Namespace": "AWS/Kinesis",
"MetricName": "GetRecords.IteratorAge",
"Dimensions": [
{
"Name": "StreamName",
"Value": {
"Ref": "StreamName"
}
}
],
"Statistic": "Average",
"Period": "300",
"EvaluationPeriods": "2",
"Threshold": {
"Ref": "Delay"
},
"ComparisonOperator": "GreaterThanThreshold",
"AlarmActions": [
{
"Ref": "AlarmTopic"
}
]
}
},
"KinesisNoDataAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Alarm if there is no data in Kinesis for 15 mins",
"Namespace": "AWS/Kinesis",
"MetricName": "IncomingRecords",
"Dimensions": [
{
"Name": "StreamName",
"Value": {
"Ref": "StreamName"
}
}
],
"Statistic": "Sum",
"Period": "300",
"EvaluationPeriods": "3",
"Threshold": 1,
"ComparisonOperator": "LessThanThreshold",
"AlarmActions": [
{
"Ref": "AlarmTopic"
}
]
}
},
"KinesisHighIncomingRecords": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Alarm if there incoming rate to Kinesis is high.",
"Namespace": "AWS/Kinesis",
"MetricName": "IncomingRecords",
"Dimensions": [
{
"Name": "StreamName",
"Value": {
"Ref": "StreamName"
}
}
],
"Statistic": "Sum",
"Period": "300",
"EvaluationPeriods": "3",
"Threshold": {
"Ref": "KinesisRecordThreshold"
},
"ComparisonOperator": "GreaterThanThreshold",
"AlarmActions": [
{
"Ref": "AlarmTopic"
}
]
}
}
},
"Outputs": {
"ClusterEndpoint": {
"Description": "Cluster JDBC Connection",
"Value": {
"Fn::Join": [
"",
[
"jdbc:postgresql://",
{
"Fn::GetAtt": [
"RedshiftCluster",
"Endpoint.Address"
]
},
":",
{
"Fn::GetAtt": [
"RedshiftCluster",
"Endpoint.Port"
]
},
"/cognito?tcpKeepAlive=true"
]
]
}
}
}
}