-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
110 lines (103 loc) · 3.62 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
# For full config options, check the docs:
# docs.serverless.com
service: data-pipeline
frameworkVersion: '3'
useDotenv: true
configValidationMode: error
plugins:
- serverless-ruby-layer
custom:
rubyLayer:
use_docker: true
currentStage: ${opt:stage, 'development'}
buckets:
inbox_bucket: es-${self:custom.currentStage}-data-inbox
process_bucket: es-${self:custom.currentStage}-data-process
compressed_bucket: es-${self:custom.currentStage}-data-uncompressed
spreadsheet_bucket: es-${self:custom.currentStage}-data-spreadsheet
amr_data_bucket: es-${self:custom.currentStage}-data-amr-data
unprocessable_bucket: es-${self:custom.currentStage}-data-unprocessable
provider:
name: aws
runtime: ruby3.2
profile: serverless
region: eu-west-2
stage: ${opt:stage, 'development'}
environment:
INBOX_BUCKET: ${self:custom.buckets.inbox_bucket}
PROCESS_BUCKET: ${self:custom.buckets.process_bucket}
COMPRESSED_BUCKET: ${self:custom.buckets.compressed_bucket}
SPREADSHEET_BUCKET: ${self:custom.buckets.spreadsheet_bucket}
AMR_DATA_BUCKET: ${self:custom.buckets.amr_data_bucket}
UNPROCESSABLE_BUCKET: ${self:custom.buckets.unprocessable_bucket}
ROLLBAR_ACCESS_TOKEN: ${env:ROLLBAR_ACCESS_TOKEN}
# this allows bundler to pick up git gems in /opt/ruby/3.2.0/bundler from the ruby layer
BUNDLE_PATH: /opt
iam:
role:
statements:
- Effect: "Allow"
Action:
- "s3:*"
Resource:
- { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ]]}
- "arn:aws:s3:::${self:custom.buckets.inbox_bucket}/*"
- "arn:aws:s3:::${self:custom.buckets.process_bucket}/*"
- "arn:aws:s3:::${self:custom.buckets.compressed_bucket}/*"
- "arn:aws:s3:::${self:custom.buckets.spreadsheet_bucket}/*"
- "arn:aws:s3:::${self:custom.buckets.amr_data_bucket}/*"
- "arn:aws:s3:::${self:custom.buckets.unprocessable_bucket}/*"
package:
patterns:
- '!**'
- 'handlers/*.rb'
- 'handler.rb'
- 'Gemfile'
- 'Gemfile.lock'
functions:
unpack-attachments:
handler: handler.DataPipeline::Handler.unpack_attachments
events:
- s3: ${self:provider.environment.INBOX_BUCKET}
process-file:
handler: handler.DataPipeline::Handler.process_file
events:
- s3: ${self:provider.environment.PROCESS_BUCKET}
uncompress:
handler: handler.DataPipeline::Handler.uncompress_file
events:
- s3: ${self:provider.environment.COMPRESSED_BUCKET}
convert:
handler: handler.DataPipeline::Handler.convert_file
events:
- s3: ${self:provider.environment.SPREADSHEET_BUCKET}
resources:
Resources:
InboxS3Policy:
Type: AWS::S3::BucketPolicy
DependsOn: S3BucketEs${self:custom.currentStage}datainbox
Properties:
Bucket:
Ref: S3BucketEs${self:custom.currentStage}datainbox
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: "SESInboxWriter"
Principal:
Service: "ses.amazonaws.com"
Condition:
StringEquals:
"aws:Referer": {Ref: 'AWS::AccountId'}
Effect: Allow
Action:
- s3:PutObject
Resource:
- arn:aws:s3:::${self:provider.environment.INBOX_BUCKET}/*
S3BucketAmrData:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.environment.AMR_DATA_BUCKET}
S3BucketUnprocessable:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.environment.UNPROCESSABLE_BUCKET}