-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
102 lines (94 loc) · 2.89 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
service:
name: marapp-workers
plugins:
- serverless-dotenv-plugin
- serverless-python-requirements
- serverless-prune-plugin
provider:
name: aws
runtime: python3.7
region: ${opt:region, self:custom.defaultRegion}
memorySize: 1024
timeout: 60
vpc:
securityGroupIds:
- ${env:VPC_SECURITY_GROUP_ID_1}
# - ...
subnetIds:
- ${env:VPC_SUBNET_ID_1}
- ${env:VPC_SUBNET_ID_2}
- ${env:VPC_SUBNET_ID_3}
- ${env:VPC_SUBNET_ID_4}
- ${env:VPC_SUBNET_ID_5}
- ${env:VPC_SUBNET_ID_6}
# - ...
environment:
GOOGLE_SERVICE_ACCOUNT: ${env:GOOGLE_SERVICE_ACCOUNT}
SERVICE_API_ENDPOINT: ${env:SERVICE_API_ENDPOINT}
SERVICE_API_KEY: ${env:SERVICE_API_KEY}
SNS_WORKER_TOPIC_ARN: ${self:custom.workerSnsTopicArn}
SNS_RESULT_TOPIC_ARN: ${env:SNS_RESULT_TOPIC_ARN}
SENTRY_DSN: ${env:SENTRY_DSN}
iamRoleStatements:
- Effect: Allow
Action:
- SNS:Publish
Resource: { "Fn::Join": [":", ["arn:aws:sns:${self:provider.region}", { "Ref": "AWS::AccountId" }, "${self:custom.managerSnsTopic}" ] ] }
- Effect: Allow
Action:
- SNS:Publish
Resource: { "Fn::Join": [":", ["arn:aws:sns:${self:provider.region}", { "Ref": "AWS::AccountId" }, "${self:custom.workerSnsTopic}" ] ] }
- Effect: Allow
Action:
- SNS:Publish
Resource: ${env:SNS_RESULT_TOPIC_ARN}
package:
# individually: true
exclude:
- ./**
include:
- src/**/*
prune:
automatic: true
number: 3
custom:
stageEnv: ${opt:stage, self:provider.stage}
defaultRegion: us-east-1
managerSnsTopic: "${self:service}-${self:custom.stageEnv}-sns-manager"
managerSnsTopicArn: { "Fn::Join": [":", ["arn:aws:sns:${self:provider.region}", { "Ref": "AWS::AccountId" }, "${self:custom.managerSnsTopic}" ] ] }
workerSnsTopic: "${self:service}-${self:custom.stageEnv}-sns-worker"
workerSnsTopicArn: { "Fn::Join": [":", ["arn:aws:sns:${self:provider.region}", { "Ref": "AWS::AccountId" }, "${self:custom.workerSnsTopic}" ] ] }
# Plugins configuration
pythonRequirements:
dockerizePip: true
dockerImage: 'lambci/lambda:build-python3.7'
dockerSsh: true
functions:
manager-handler:
timeout: 30
memorySize: 512
reservedConcurrency: 20
handler: src/handlers/manager_handler.lambda_handler
events:
- sns:
arn: !Ref SNSManagerTopic
topicName: ${self:custom.managerSnsTopic}
worker-handler:
timeout: 900
memorySize: 512
reservedConcurrency: 20
handler: src/handlers/worker_handler.lambda_handler
events:
- sns:
arn: !Ref SNSWorkerTopic
topicName: ${self:custom.workerSnsTopic}
resources:
Resources:
SNSManagerTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${self:custom.managerSnsTopic}
SNSWorkerTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${self:custom.workerSnsTopic}