-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
90 lines (84 loc) · 2.95 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
service: s3-product-feed
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: us-east-1
environment:
FEED_DELIMITER: ${self:custom.config.feedDelimiter}
OUTPUT_BUCKET: ${self:custom.app-name}-${self:service}-${self:custom.config.stage}-${self:custom.config.outputBucket}
CONFIG_BUCKET: ${self:custom.app-name}-${self:service}-${self:custom.config.stage}-${self:custom.config.configBucket}
plugins:
- serverless-plugin-typescript
- serverless-offline
custom:
config: ${file(config.json)}
app-name: ${self:custom.config.appName}
s3Buckets:
SOURCES_BUCKET: ${self:custom.app-name}-${self:service}-${self:custom.config.stage}-sources-bucket
iamRoleStatements:
- Effect: Allow
Action:
- lambda:InvokeFunction
- s3:*
Resource:
- "arn:aws:lambda:${self:custom.config.region}:*:function:*"
- "arn:aws:ses:${self:custom.config.region}:*"
- "arn:aws:ses:${self:custom.config.region}:*:identity/*"
- "arn:aws:s3:::${self:custom.s3Buckets.SOURCES_BUCKET}/*"
- "arn:aws:s3:::${self:custom.s3Buckets.SOURCES_BUCKET}"
- "arn:aws:s3:::${self:environment.OUTPUT_BUCKET}/*"
- "arn:aws:s3:::${self:environment.OUTPUT_BUCKET}"
- "arn:aws:s3:::${self:environment.CONFIG_BUCKET}/*"
- "arn:aws:s3:::${self:environment.CONFIG_BUCKET}"
- "arn:aws:logs:${self:custom.config.region}:*:log-group:*"
- "arn:aws:logs:${self:custom.config.region}:*:log-group:*:*:*"
functions:
feed:
handler: src/handlers/feed.run
timeout: 900
environment:
FUNCTION_PREFIX: ${self:service}-${opt:stage, self:provider.stage}
events:
- s3:
bucket: ${self:custom.s3Buckets.SOURCES_BUCKET}
event: s3:ObjectCreated:*
existing: true
resources:
Resources:
S3BucketFeedSources:
Type: AWS::S3::Bucket
Properties:
BucketName: '${self:custom.s3Buckets.SOURCES_BUCKET}'
TransformLambdaPermissionS3:
Type: 'AWS::Lambda::Permission'
Properties:
FunctionName:
'Fn::GetAtt':
- FeedLambdaFunction
- Arn
Principal: 's3.amazonaws.com'
Action: 'lambda:InvokeFunction'
SourceAccount:
Ref: AWS::AccountId
SourceArn: 'arn:aws:s3:::${self:custom.s3Buckets.SOURCES_BUCKET}'
S3BucketFeedOutput:
Type: AWS::S3::Bucket
Properties:
BucketName: '${self:provider.environment.OUTPUT_BUCKET}'
S3BucketConfiguration:
Type: AWS::S3::Bucket
Properties:
BucketName: '${self:provider.environment.CONFIG_BUCKET}'
LambdaWritePermissionS3:
Type: 'AWS::Lambda::Permission'
Properties:
FunctionName:
'Fn::GetAtt':
- FeedLambdaFunction
- Arn
Principal: 's3.amazonaws.com'
Action: 'lambda:InvokeFunction'
SourceAccount:
Ref: AWS::AccountId
SourceArn: 'arn:aws:s3:::${self:provider.environment.OUTPUT_BUCKET}'