-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
119 lines (112 loc) · 2.67 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
service: daily-report-mailer
frameworkVersion: "2"
package:
include:
- 'assets/**'
custom:
serverless-offline-sns:
port: 7001
debug: false
dynamodb:
stages:
- local
- dev
- test
- debug
start:
seed: true
migrate: true
port: 7000
inMemory: true
seed:
assets:
sources:
- table: ${env:DYNAMO_TABLE_PREFIX}.SquadConfiguration
sources: [./migrations/seeds/squad-configuration.json]
prune:
automatic: true
number: 2
plugins:
- serverless-dotenv-plugin
- serverless-deployment-bucket
- serverless-prune-plugin
- serverless-plugin-lambda-dead-letter
- serverless-plugin-typescript
- serverless-dynamodb-local
- serverless-offline-sns
- serverless-offline
provider:
name: aws
runtime: nodejs14.x
lambdaHashingVersion: 20201221
deploymentBucket:
name: daily-report-mailer-service-${opt:stage, 'local'}
serverSideEncryption: AES256
tracing:
lambda: true
stage: ${opt:stage, 'local'}
region: ${opt:region, 'us-east-1'}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Scan
- xray:PutTraceSegments
- xray:PutTelemetryRecords
Resource:
- "Fn::GetAtt": [ SquadConfigurationTable, Arn ]
- Effect: Allow
Action:
- sns:Publish
- sns:Subscribe
Resource:
- !Ref ReportTopic
- Effect: Allow
Action:
- sqs:SendMessage
Resource:
- "Fn::GetAtt": [ ReportDLQ, Arn ]
functions:
Produce:
handler: src/messaging/handler.produce
events:
- schedule: cron(30 20 ? * MON-FRI *)
environment:
TOPIC_ARN:
!Ref ReportTopic
Consume:
handler: src/messaging/handler.consume
memorySize: 1600
timeout: 60
events:
- sns:
arn: !Ref ReportTopic
topicName: ${env:SNS_SQS_PREFIX}
deadLetter:
targetArn:
GetResourceArn: ReportDLQ
resources:
Resources:
SquadConfigurationTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${env:DYNAMO_TABLE_PREFIX}.SquadConfiguration
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
ReportTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${env:SNS_SQS_PREFIX}
ReportDLQ:
Type: AWS::SQS::Queue
Properties:
QueueName: ${env:SNS_SQS_PREFIX}-dlq