This repository has been archived by the owner on Jun 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
85 lines (80 loc) · 2.15 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
org: networkadmin
app: dazser-mailer-app
service: dazser-mandrill-runner
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: us-east-1
environment:
DYNAMODB_TABLE: !Ref DynamoDbTable
SQS_QUEUE_NAME: !GetAtt SQSQueue.QueueName
SQS_QUEUE_ARN: !GetAtt SQSQueue.Arn
SQS_QUEUE_URL: !Ref SQSQueue
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
Resource: !GetAtt DynamoDbTable.Arn
custom:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
SQS_QUEUE_NAME: ${self:service}-${opt:stage, self:provider.stage}
# you can add packaging information here
package:
exclude:
- typescript/**
functions:
sendPayloadToMandrill:
handler: dist/handler.sendPayloadToMandrill
timeout: 120
events:
- sqs:
arn: !GetAtt SQSQueue.Arn
batchSize: 1
resources:
Resources:
DynamoDbTable:
Type: "AWS::DynamoDB::Table"
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TimeToLiveSpecification:
AttributeName: expires
Enabled: true
TableName: ${self:custom.DYNAMODB_TABLE}
SQSDLQQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: dlq-${self:custom.SQS_QUEUE_NAME}
KmsMasterKeyId: alias/aws/sqs
KmsDataKeyReusePeriodSeconds: 12000
SQSQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: ${self:custom.SQS_QUEUE_NAME}
KmsMasterKeyId: alias/aws/sqs
KmsDataKeyReusePeriodSeconds: 12000
VisibilityTimeout: 600
RedrivePolicy:
deadLetterTargetArn: !GetAtt SQSDLQQueue.Arn
maxReceiveCount: 5
Outputs:
DynamoDbTableName:
Value: !Ref DynamoDbTable
DynamoDbTableArn:
Value: !GetAtt DynamoDbTable.Arn
SQSDLQQueueArn:
Value: !GetAtt SQSDLQQueue.Arn
SQSQueueArn:
Value: !GetAtt SQSQueue.Arn