-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
83 lines (76 loc) · 2.73 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
service: sendgrid-receiver
provider:
name: aws
runtime: python3.8
# Resolution of lambda version hashes was improved with better algorithm, which will be used in v3.0.0.
# More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
lambdaHashingVersion: 20201221
profile: ${env:SLS_PROF}
region: ${env:SLS_REGION}
stage: ${opt:stage}
logRetentionInDays: 7 # CloudWatchLog
iamRoleStatements:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
- s3:PutObject
Resource: '*'
plugins:
# - serverless-offline-python
- serverless-prune-plugin # deletes old version of CloudFormation stack deployments
- serverless-plugin-stage-variables # for apigw logging
- serverless-python-requirements # allow pip
custom:
prune: # retain 3 generations of CloudFormation stack configs in S3 buckets
atuomatic: true
number: 3
pythonRequirements:
dockerizePip: true
resources:
Description: ${self:provider.stage} CloudFormation stack
Resources:
ApiGatewayRestApi: # setting name and description of APIGW
Type: AWS::ApiGateway::RestApi
Properties:
Name: sendgrid-receiver-api
Description: SendGrid receiver API (Lambda-proxy integration)
ApiGatewayStage: # for apigw logging
Type: AWS::ApiGateway::stage
Properties:
MethodSettings:
- DataTraceEnabled: true
HttpMethod: '*'
LoggingLevel: INFO
ResourcePath: '/*'
MetricsEnabled: true
functions: # Lambda configuration
'sendgrid-receiver':
handler: lambda_function.lambda_handler
name: sendgrid-receiver-function-${self:provider.stage}
description: ${self:provider.stage} Lambda function
events: # define resources one by one to save Lambda from consumption
- http:
path: /receive
method: post
cors: false
environment:
BUCKET_NAME: ${env:BUCKET_NAME}
WEBHOOK_URL: ${env:WEBHOOK_URL}
BASEPATH: ${env:BASEPATH}
package:
patterns:
- '!**'
- 'lambda_function.py'
- 'template_email_html.j2'
- 'requirements.txt'
- '.env'
# Starting with v3.0.0, Serverless will throw on configuration errors by default.
# More Info: https://www.serverless.com/framework/docs/deprecations/#CONFIG_VALIDATION_MODE_DEFAULT
configValidationMode: error
# just to deprecation ignore warning
useDotenv: true
# Starting with next major release, this will be communicated with a thrown error. Set "variablesResolutionMode: 20210326" in your service config, to adapt to this behavior now
# More Info: https://www.serverless.com/framework/docs/deprecations/#NEW_VARIABLES_RESOLVER
variablesResolutionMode: 20210326