-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkinesis-demo.yaml
176 lines (164 loc) · 5.13 KB
/
kinesis-demo.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
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS CloudFormation Template for Kenisis Demo'
Parameters:
BucketName:
Description: Name of Bucket where we can host our static website
Type: String
Resources:
S3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Ref BucketName
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
BucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
PolicyDocument:
Id: MyPolicy
Version: 2012-10-17
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: '*'
Action: 's3:GetObject'
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref S3Bucket
- /*
Bucket: !Ref S3Bucket
MyStream:
Type: "AWS::Kinesis::Stream"
Properties:
Name: kinesis-demo
ShardCount: 1
MySecondStream:
Type: "AWS::Kinesis::Stream"
Properties:
Name: kinesis-demo-second-stream
ShardCount: 1
BasicApplication:
Type: "AWS::KinesisAnalytics::Application"
Properties:
ApplicationName: "kenisis-demo-application"
ApplicationDescription: "Analytics for demo app"
ApplicationCode: "CREATE OR REPLACE STREAM \"DESTINATION_SQL_STREAM\" (ticker_symbol VARCHAR(4), ticker_symbol_count INTEGER);\nCREATE OR REPLACE PUMP \"STREAM_PUMP\" AS INSERT INTO \"DESTINATION_SQL_STREAM\"\nSELECT STREAM QUADRANT, COUNT(*) OVER TEN_SECOND_SLIDING_WINDOW AS ticker_symbol_count FROM \"SOURCE_SQL_STREAM_001\" WINDOW TEN_SECOND_SLIDING_WINDOW AS (PARTITION BY quadrant RANGE INTERVAL '10' SECOND PRECEDING);"
Inputs:
- NamePrefix: "SOURCE_SQL_STREAM"
InputSchema:
RecordColumns:
- Name: "POSITIONX"
SqlType: "INTEGER"
Mapping: "$.POSITIONX"
- Name: "POSITIONY"
SqlType: "INTEGER"
Mapping: "$.POSITIONY"
- Name: "QUADRANT"
SqlType: "VARCHAR(4)"
Mapping: "$.QUADRANT"
- Name: "GUID"
SqlType: "DOUBLE"
Mapping: "$.GUID"
RecordFormat:
RecordFormatType: "JSON"
MappingParameters:
JSONMappingParameters:
RecordRowPath: "$"
KinesisStreamsInput:
ResourceARN: !GetAtt MyStream.Arn
RoleARN: !GetAtt KinesisAnalyticsRole.Arn
BasicApplicationOutputs:
Type: "AWS::KinesisAnalytics::ApplicationOutput"
DependsOn: BasicApplication
Properties:
ApplicationName: !Ref BasicApplication
Output:
DestinationSchema:
RecordFormatType: "CSV"
KinesisStreamsOutput:
ResourceARN: !GetAtt MySecondStream.Arn
RoleARN: !GetAtt KinesisAnalyticsRole.Arn
KinesisAnalyticsRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: kinesisanalytics.amazonaws.com
Action: "sts:AssumeRole"
Path: "/"
Policies:
- PolicyName: Open
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "*"
Resource: "*"
MyCognitoPool:
Type: "AWS::Cognito::IdentityPool"
Properties:
IdentityPoolName: myCognitoPool
AllowUnauthenticatedIdentities: true
IamRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: "kenisis-demo-role"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action:
- "sts:AssumeRoleWithWebIdentity"
Condition: { "ForAnyValue:StringLike": {"cognito-identity.amazonaws.com:amr": "unauthenticated" }, "StringEquals": {"cognito-identity.amazonaws.com:aud": !Ref MyCognitoPool}}
Principal:
Federated:
- "cognito-identity.amazonaws.com"
Path: "/"
Policies:
-
PolicyName: main
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action:
- "mobileanalytics:PutEvents"
- "cognito-sync:*"
Resource: "*"
-
Effect: "Allow"
Action: "kinesis:Put*"
Resource: !GetAtt MyStream.Arn
IdentityPoolRoleAttachment:
Type: AWS::Cognito::IdentityPoolRoleAttachment
Properties:
IdentityPoolId: !Ref MyCognitoPool
Roles:
unauthenticated: !GetAtt IamRole.Arn
authenticated: !GetAtt IamRole.Arn
Outputs:
myCognitoPoolId:
Description: The id of the cognito pool
Value: !Ref MyCognitoPool
WebsiteURL:
Value: !GetAtt
- S3Bucket
- WebsiteURL
Description: URL for website hosted on S3
S3BucketSecureURL:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- S3Bucket
- DomainName
Description: Name of S3 bucket to hold website content