-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresources.yaml
273 lines (243 loc) · 7.62 KB
/
resources.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
Parameters:
ResourceSuffix:
Description: Suffix to append to all resources
Type: String
Default: ""
BucketName:
Description: Name of the S3 bucket
Type: String
Default: "ob-publish"
Resources:
#######################################################
# Policies
#######################################################
CommonAccessPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: Policy to grant common access to DynamoDB tables and CloudFormation outputs
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:Query
- dynamodb:Scan
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- !GetAtt ObSessionTable.Arn
- !GetAtt ObAgentConfigTable.Arn
- !GetAtt ObEventActionTable.Arn
- !GetAtt ObClientTable.Arn
- Effect: Allow
Action:
- cloudformation:DescribeStacks
Resource: !Sub 'arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${AWS::StackName}/*'
- Effect: Allow
Action:
- sns:Publish
Resource:
- !Sub 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:ObInfra-${ResourceSuffix}'
- !Sub 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:ObBusiness-${ResourceSuffix}'
# - Effect: Allow
# Action:
# - s3:PutObject
# - s3:GetObject
# Resource: !GetAtt ObBucket.Arn
ObBucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Sub '${BucketName}'
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
ObBucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket:
Ref: 'ObBucket'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal: '*'
Action:
- s3:GetObject
- s3:PutObject
Resource:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- Ref: 'ObBucket'
- '/*'
InfraTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: !Sub
- 'ObInfra-${ResourceSuffix}'
- ResourceSuffix: !Ref ResourceSuffix
DisplayName: Infrastructure Notifications
BusinessTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: !Sub
- 'ObBusiness-${ResourceSuffix}'
- ResourceSuffix: !Ref ResourceSuffix
DisplayName: Business Notifications
#######################################################
# Tables
#######################################################
ObSessionTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: client_id
AttributeType: S
- AttributeName: session_id
AttributeType: S
KeySchema:
- AttributeName: client_id
KeyType: HASH
- AttributeName: session_id
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: !Sub
- 'ObSessionTable-${ResourceSuffix}'
- ResourceSuffix: !Ref ResourceSuffix
ObAgentConfigTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: client_id
AttributeType: S
- AttributeName: profile_name
AttributeType: S
KeySchema:
- AttributeName: client_id
KeyType: HASH
- AttributeName: profile_name
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: !Sub
- 'ObAgentConfigTable-${ResourceSuffix}'
- ResourceSuffix: !Ref ResourceSuffix
ObEventActionTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: action_id
AttributeType: S
- AttributeName: session_id
AttributeType: S
KeySchema:
- AttributeName: action_id
KeyType: HASH
- AttributeName: session_id
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: !Sub
- 'ObEventActionTable-${ResourceSuffix}'
- ResourceSuffix: !Ref ResourceSuffix
ObClientTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: email
AttributeType: S
- AttributeName: leadmo_location_id
AttributeType: S
KeySchema:
- AttributeName: email
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: !Sub
- 'ObClientTable-${ResourceSuffix}'
- ResourceSuffix: !Ref ResourceSuffix
GlobalSecondaryIndexes:
- IndexName: LocationIndex
KeySchema:
- AttributeName: leadmo_location_id
KeyType: HASH
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Outputs:
ObSessionTableName:
Description: ObSessionTable
Value: !Ref ObSessionTable
Export:
Name: !Sub '${AWS::StackName}-ObSessionTableName'
ObAgentConfigTableName:
Description: ObAgentConfigTable
Value: !Ref ObAgentConfigTable
Export:
Name: !Sub '${AWS::StackName}-ObAgentConfigTableName'
ObClientTableName:
Description: ObClientTable
Value: !Ref ObClientTable
Export:
Name: !Sub '${AWS::StackName}-ObClientTableName'
ObActionTableName:
Description: ObEventActionTable
Value: !Ref ObEventActionTable
Export:
Name: !Sub '${AWS::StackName}-ObEventActionTableName'
ObEventActionTableName:
Description: ObEventActionTable
Value: !Ref ObEventActionTable
Export:
Name: !Sub '${AWS::StackName}-ObActionTableName'
ObSessionTableArn:
Description: ObSessionTableArn
Value: !GetAtt ObSessionTable.Arn
Export:
Name: !Sub '${AWS::StackName}-ObSessionTableArn'
ObAgentConfigTableArn:
Description: ObAgentConfigTableArn
Value: !GetAtt ObAgentConfigTable.Arn
Export:
Name: !Sub '${AWS::StackName}-ObAgentConfigTableArn'
ObEventActionTableArn:
Description: ObEventActionTable
Value: !GetAtt ObEventActionTable.Arn
Export:
Name: !Sub '${AWS::StackName}-ObEventActionTableArn'
ObActionTableArn:
Description: ObEventActionTable
Value: !GetAtt ObEventActionTable.Arn
Export:
Name: !Sub '${AWS::StackName}-ObActionTableArn'
ObClientTableArn:
Description: ObClientTableArn
Value: !GetAtt ObClientTable.Arn
Export:
Name: !Sub '${AWS::StackName}-ObClientTableArn'
ObBucketArn:
Description: ObBucketArn
Value: !GetAtt ObBucket.Arn
Export:
Name: !Sub '${AWS::StackName}-ObBucketArn'
CommonAccessPolicyArn:
Description: CommonAccessPolicyArn
Value: !Ref CommonAccessPolicy
Export:
Name: !Sub '${AWS::StackName}-CommonAccessPolicyArn'
ObBucketName:
Description: ObBucketName
Value: !Ref ObBucket
Export:
Name: !Sub '${AWS::StackName}-ObBucketName'