-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
117 lines (109 loc) · 3.39 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
service: ${env:SERVICE}
provider:
name: aws
runtime: nodejs12.x
stage: ${env:STAGE}
region: ${env:REGION}
# apiKeys:
# - ${env:STAGE}-${env:SERVICE}Key
usagePlan:
quota:
limit: ${env:QUOTA_LIMIT}
offset: ${env:QUOTA_OFFSET}
period: ${env:QUOTA_PERIOD}
throttle:
burstLimit: ${env:THROTTLE_BURST_LIMIT}
rateLimit: ${env:THROTTLE_RATE_LIMIT}
plugins:
- serverless-pseudo-parameters
- serverless-dotenv-plugin
- serverless-iam-roles-per-function
functions:
add-expense:
handler: src/handlers/add-expense.handler
description: Financial Control API - Add Expense
timeout: 300
events:
- stream:
arn: arn:aws:kinesis:${env:REGION}:#{AWS::AccountId}:stream/${env:EXPENSES_STREAM}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:query
- dynamodb:UpdateItem
Resource: arn:aws:dynamodb:${env:REGION}:#{AWS::AccountId}:table/${env:EXPENSES_CATEGORIES_TABLE}
create-expense:
handler: src/handlers/create-expense.handler
description: Financial Control API - Create Expense
timeout: 30
events:
- http:
path: expenses
method: post
iamRoleStatements:
- Effect: Allow
Action: kinesis:PutRecord
Resource: arn:aws:kinesis:${env:REGION}:#{AWS::AccountId}:stream/${env:EXPENSES_STREAM}
get-categories:
handler: src/handlers/get-categories.handler
description: Financial Control API - Get All Categories
timeout: 30
events:
- http:
path: categories
method: get
iamRoleStatements:
- Effect: Allow
Action: dynamodb:scan
Resource: arn:aws:dynamodb:${env:REGION}:#{AWS::AccountId}:table/${env:EXPENSES_CATEGORIES_TABLE}
get-expenses:
handler: src/handlers/get-expenses.handler
description: Financial Control API - Get All Expenses
timeout: 30
events:
- http:
path: expenses
method: get
notify-expense:
handler: src/handlers/notify-expense.handler
description: Financial Control API - Notify Expense
timeout: 300
events:
- stream:
arn: arn:aws:kinesis:${env:REGION}:#{AWS::AccountId}:stream/${env:EXPENSES_STREAM}
environment:
EXPENSE_NOTIFICATION_TOPIC_ARN: arn:aws:sns:${env:REGION}:#{AWS::AccountId}:${env:EXPENSE_NOTIFICATION_TOPIC}
iamRoleStatements:
- Effect: Allow
Action: kinesis:PutRecord
Resource: arn:aws:kinesis:${env:REGION}:#{AWS::AccountId}:stream/${env:EXPENSES_STREAM}
- Effect: Allow
Action: sns:Publish
Resource: arn:aws:sns:${env:REGION}:#{AWS::AccountId}:${env:EXPENSE_NOTIFICATION_TOPIC}
#resources:
# Resources:
# expensesCategoriesTable:
# Type: AWS::DynamoDB::Table
# Properties:
# TableName: ${env:EXPENSES_CATEGORIES_TABLE}
# AttributeDefinitions:
# - AttributeName: name
# AttributeType: S
# KeySchema:
# - AttributeName: name
# KeyType: HASH
# ProvisionedThroughput:
# ReadCapacityUnits: 1
# WriteCapacityUnits: 1
#
# expenseEventsStream:
# Type: AWS::Kinesis::Stream
# Properties:
# Name: ${env:EXPENSES_STREAM}
# ShardCount: 1
#
# expenseNotificationTopic:
# Type: AWS::SNS::Topic
# Properties:
# DisplayName: ${env:EXPENSE_NOTIFICATION_TOPIC}
# TopicName: ${env:EXPENSE_NOTIFICATION_TOPIC}