-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
237 lines (226 loc) · 6.29 KB
/
serverless.yml
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
service: monetization
custom:
eventBus: arn:aws:events:${self:provider.region}:779089996899:event-bus/ncent-${opt:stage}
authorizer: ${ssm:/ncnt/${opt:stage}/authorizer}
provider:
name: aws
stage: ${opt:stage}
runtime: go1.x
region: us-west-2
iamRoleStatements:
- Effect: Allow
Resource: "*"
Action:
- dynamodb:DeleteItem
- dynamodb:UpdateItem
- dynamodb:PutItem
- dynamodb:ListTables
- dynamodb:DescribeTable
- dynamodb:DescribeStream
- dynamodb:ListStreams
- dynamodb:GetShardIterator
- dynamodb:BatchGetItem
- dynamodb:GetItem
- dynamodb:Query
- dynamodb:Scan
- dynamodb:DescribeReservedCapacity
- dynamodb:DescribeReservedCapacityOfferings
- dynamodb:GetRecords
- ec2:DescribeVpcs
- ec2:DescribeSubnets
- ec2:DescribeNetworkInterfaces
- ec2:DescribeAddresses
- ec2:AssociateAddress
- ec2:DisassociateAddress
- ec2:CreateNetworkInterface
- ec2:DeleteNetworkInterface
- ec2:ModifyNetworkInterfaceAttribute
- s3:Get*
- s3:List*
- logs:*
- ses:*
- events:*
package:
exclude:
stage: ${opt:stage}
- ./**
include:
- ./bin/**
functions:
plans:
handler: bin/eventbridge/plans
environment:
STAGE: ${opt:stage}
events:
- eventBridge:
eventBus: ${self:custom.eventBus}
pattern:
source:
- ${opt:stage}.admin.plans
detail-type:
- plan-created
- plan-updated
subscriptions:
handler: bin/eventbridge/subscriptions
environment:
STAGE: ${opt:stage}
events:
- eventBridge:
eventBus: ${self:custom.eventBus}
pattern:
source:
- "${opt:stage}.monetization"
detail-type:
- subscription-created
- subscription-cancelled
validate:
handler: bin/eventbridge/validate/challenge
environment:
STAGE: ${opt:stage}
DB_HOST: ${opt:db_host}
DB_PASSWD: ${opt:db_passwd}
events:
- eventBridge:
eventBus: ${self:custom.eventBus}
pattern:
source:
- ${opt:stage}.user.challenge
detail-type:
- challenge-created
- challenge-shared
new_subscription_email:
handler: bin/eventbridge/new_subscription_email
environment:
STAGE: ${opt:stage}
events:
- eventBridge:
eventBus: ${self:custom.eventBus}
pattern:
source:
- "${opt:stage}.monetization"
detail-type:
- subscription-created
create_auth0_user:
handler: bin/eventbridge/create_auth0_user
environment:
STAGE: ${opt:stage}
AUTH0_CLIENT_ID: ${opt:auth0_client_id}
AUTH0_SECRET: ${opt:auth0_secret}
events:
- eventBridge:
eventBus: ${self:custom.eventBus}
pattern:
source:
- "${opt:stage}.monetization"
detail-type:
- subscription-created
e2e_webhook:
handler: bin/apigateway/e2e_webhook
events:
- http:
path: /e2e_webhook
method: post
cors: true
get_subscriptions:
handler: bin/apigateway/subscriptions
environment:
STAGE: ${opt:stage}
events:
- http:
path: /subscriptions
method: get
authorizer: ${self:custom.authorizer}
cors: true
resources:
Resources:
DynamoDBTablePlans:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-plans-${opt:stage}
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
DynamoDBTableCriteria:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-criteria-${opt:stage}
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
DynamoDBTableSubscriptions:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-subscriptions-${opt:stage}
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
DynamoDBTableQuotas:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-quotas-${opt:stage}
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
DynamoDBTablePaymentServices:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-payment-services-${opt:stage}
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
DynamoDBTablePaymentMethods:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-payment-methods-${opt:stage}
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
DynamoDBTableTransactions:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-transactions-${opt:stage}
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5