-
Notifications
You must be signed in to change notification settings - Fork 16
/
serverless.yml
122 lines (116 loc) · 3.41 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
120
121
122
service: python-sesdynamodb-contactform
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
plugins:
- serverless-domain-manager
custom:
secrets: ${file(secrets.json)}
customDomain:
domainName: ${self:custom.secrets.DOMAIN}
certificateName: ${self:custom.secrets.CERTIFICATE}
stage: ${self:provider.stage}
createRoute53Record: true
provider:
name: aws
runtime: python3.6
region: ${self:custom.secrets.REGION}
profile: ${self:custom.secrets.PROFILE}
stage: ${self:custom.secrets.ENV}
memory: ${self:custom.secrets.MEMORY}
timeout: ${self:custom.secrets.TIMEOUT}
apiKeys:
- ${self:provider.stage}-contactForm
- ${self:provider.stage}-list
usagePlan:
quota:
limit: 10000
offset: 2
period: MONTH
throttle:
burstLimit: 500
rateLimit: 250
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
SENDER_EMAIL: ${self:custom.secrets.SENDER_EMAIL}
EMAIL_SUBJECT: ${self:custom.secrets.EMAIL_SUBJECT}
SES_REGION: ${self:custom.secrets.SES_REGION, 'us-east-1'}
CONFIG_SET: ConfigSet
iamRoleStatements:
- Effect: "Allow"
Action:
- ses:SendEmail
- ses:SendRawEmail
Resource: "*"
- Effect: Allow
Action:
- dynamodb:Scan
- dynamodb:PutItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
functions:
sendMail:
handler: handler.sendMail
description: Send Email using AWS SES Service
events:
- http:
path: sendMail
method: post
async: false
private: true
integration: lambda
cors:
origins:
- ${self:custom.secrets.ORIGINS.${self:provider.stage}}
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
allowCredentials: false
response:
headers:
"Access-Control-Allow_Origin": "'${self:custom.secrets.ORIGINS.${self:provider.stage}}'"
list:
handler: handler.list
description: List all the contact form submissions
events:
- http:
path: list
method: get
async: false
private: true
integration: lambda
cors:
origins:
- ${self:custom.secrets.ORIGINS.${self:provider.stage}}
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
allowCredentials: false
response:
headers:
"Access-Control-Allow_Origin": "'${self:custom.secrets.ORIGINS.${self:provider.stage}}'"
resources:
Resources:
ContactFormDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_TABLE}