-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
102 lines (87 loc) · 2.57 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
service:
name: serverless-paymail-eventsource
plugins:
- serverless-webpack
- serverless-offline-sns
- serverless-offline
provider:
name: aws
runtime: nodejs10.x
stage: ${opt:stage,'local'}
region: ${opt:region, 'ap-southeast-1'}
memorySize: 256
environment:
LOG_LEVEL: ${self:custom.config.LOG_LEVEL}
custom:
config:
LOG_LEVEL: ${opt:LOG_LEVEL:'info'}
STREAM_ARN: ${opt:STREAM_ARN}
webpack:
includeModules: true
keepOutputDirectory: true
serverless-offline-sns:
debug: true
functions:
eventDispatcher:
handler: src/dynamoDbStreamHandler.handle
role: EventDispatcherFunctionRole
events:
- stream:
type: dynamodb
arn: ${self:custom.config.STREAM_ARN}
environment:
TOPIC_ARN:
Ref: EventSourceTopic
iamRoleStatements:
- Effect: "Allow"
Action:
- "sns:Publish"
Resource: "arn:aws:sns:*:*:*"
resources:
Resources:
EventSourceTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: 'Topic to which serverless-paymail events are published'
TopicName: ${self:service}-${self:provider.stage}-topic
EventDispatcherFunctionRole:
Type: AWS::IAM::Role
Properties:
Path: /
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ${self:provider.stage}-EventDispatcherFunctionRole-policy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
Fn::Join:
- ":"
- - "arn:aws:logs"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "log-group:/aws/lambda/*:*:*"
- Effect: Allow
Action:
- SNS:Publish
Resource:
Ref: EventSourceTopic
- Effect: Allow
Action:
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:DescribeStream
- dynamodb:ListStreams
Resource: ${self:custom.config.STREAM_ARN}