This repository has been archived by the owner on Aug 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless-db.yml
80 lines (76 loc) · 2.56 KB
/
serverless-db.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
service: listing-db
frameworkVersion: '>=1.28.0 <2.0.0'
provider:
name: aws
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
resources:
Resources:
# main table that stores subscriptions for the newsletters
SubscriptionsDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: ${self:custom.subscribersTableName}
AttributeDefinitions:
- AttributeName: newsletter
AttributeType: S
- AttributeName: email
AttributeType: S
KeySchema:
- AttributeName: newsletter
KeyType: HASH
- AttributeName: email
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
# table that will store complains and bounces from AWS SES
# received through SNS notifications topic SESNotificationsTopic
SesNotificationsDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: ${self:custom.snsTableName}
AttributeDefinitions:
- AttributeName: email
AttributeType: S
- AttributeName: notification
AttributeType: S
KeySchema:
- AttributeName: email
KeyType: HASH
- AttributeName: notification
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
# SNS topic that will receive notifications from AWS SES
SESNotificationsTopic:
Type: 'AWS::SNS::Topic'
Properties:
TopicName: ${self:custom.snsTopicName}
# Outputs contain ARNs of tables and sns topics used by lambdas
# in the serverless-api.yml file. This allows to deploy them separately
# since DB and SNS resources will almost never change unlike API code
Outputs:
SubscriptionsTableArn:
Description: The ARN of the subscription table
Value:
Fn::GetAtt:
- SubscriptionsDynamoDBTable
- Arn
Export:
Name: ${self:provider.stage}-ListingSubscriptionsTableArn
NotificationsTableArn:
Description: The ARN of the notifications table
Value:
Fn::GetAtt:
- SesNotificationsDynamoDBTable
- Arn
Export:
Name: ${self:provider.stage}-ListingNotificationsTableArn
NotificationsTopicArn:
Description: The ARN of the SNS topic
Value:
Ref: SESNotificationsTopic
Export:
Name: ${self:provider.stage}-ListingNotificationsTopicArn
custom:
subscribersTableName: ${opt:stage, 'dev'}-listing-subscribers
snsTableName: ${opt:stage, 'dev'}-listing-sesnotify
snsTopicName: ${opt:stage, 'dev'}-listing-ses-notifications