-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
96 lines (91 loc) · 2.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
service: email
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'prod'}
timeout: 15
region: eu-west-1
vpc:
securityGroupIds:
- ${ssm:/API/SecurityGroup}
subnetIds:
- ${ssm:/API/Subnet}
iamRoleStatements:
- Effect: 'Allow'
Action:
- 'sns:Publish'
Resource:
- ${ssm:/email/SNS/arn}
- Effect: Allow
Action:
- dynamodb:*
Resource:
- ${ssm:/dynamodb/conversations/arn}
- ${ssm:/dynamodb/connections/arn}
- ${ssm:/dynamodb/email_msg_replies/arn}
functions:
email:
handler: src/handler.email
events:
- sns:
arn: ${ssm:/email/SNS/arn}
maximumRetryAttempts: 0
environment:
stage: ${self:provider.stage}
AWS_KEY_ID: ${ssm:/email/AwsKeyId}
AWS_KEY_SECRET: ${ssm:/email/AwsKeySecret~true}
SENDGRID_KEY: ${ssm:/email/SendGridKey~true}
DB_HOST: ${ssm:/DB/Host}
DB_PROXY_HOST: ${ssm:/DB/Proxy/Host}
DB_PORT: ${ssm:/DB/Port}
DB_NAME: ${ssm:/DB/Name}
DB_USER: ${ssm:/email/DB/User}
DB_PASSWORD: ${ssm:/email/DB/Password~true}
BUCKET_URL: ${ssm:/API/ProfilePictures/BucketUrl}
inbound:
handler: src/inbound.inbound
events:
- http:
path: /inbound
method: post
environment:
EMAIL_SECRET: ${ssm:/email/secret~true}
API_URL: ${ssm:/email/API/endpoint}
stepFunctions:
stateMachines:
bufferThreadMsg:
name: MsgBufferStateMachine
definition:
StartAt: Buffer
States:
Buffer:
Type: Wait
Seconds: 240
Next: Send
Send:
Type: Task
Resource: arn:aws:states:::sns:publish
Parameters:
TopicArn: ${ssm:/email/SNS/arn}
Message:
action: SEND_EMAIL
template: THREAD_MSGS
user.$: $.user
channel.$: $.channel
End: true
plugins:
- serverless-webpack
- serverless-offline
- serverless-offline-sns
- serverless-step-functions
custom:
serverless-offline:
httpPort: 4000
noPrependStageInUrl: true
webpack:
webpackConfig: 'webpack.config.js'
packager: 'npm'
includeModules: true
serverless-offline-sns:
port: 4002
debug: false