-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
71 lines (68 loc) · 2.29 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
service: notice-email-parser
provider:
name: aws
runtime: python3.8
stage: prod
iamRoleStatements:
- Effect: Allow
Action:
- s3:*
Resource: "arn:aws:s3:::${ssm:/${self:provider.stage}/lambda/notice-emails/s3/bucket~true}/*"
environment:
S3_BUCKET: ${ssm:/${self:provider.stage}/lambda/notice-emails/s3/bucket~true}
SENTRY_DSN: ${ssm:/${self:provider.stage}/lambda/notice-emails/sentry/dsn~true}
stackTags:
project: city-scrapers
environment: ${self:provider.stage}
tags:
project: city-scrapers
environment: ${self:provider.stage}
functions:
parse_notice_email:
handler: handler.handler
events:
- s3:
bucket: ${ssm:/${self:provider.stage}/lambda/notice-emails/s3/bucket~true}
event: s3:ObjectCreated:*
existing: true
rules:
- prefix: inbound/
resources:
Resources:
EmailBucketPermission:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: ${ssm:/${self:provider.stage}/lambda/notice-emails/s3/bucket~true}
PolicyDocument:
Statement:
- Principal: "*"
Action:
- s3:GetObject
Effect: Allow
Sid: AllowPublicRead
Resource: "arn:aws:s3:::${ssm:/${self:provider.stage}/lambda/notice-emails/s3/bucket~true}/*"
- Principal:
Service: "ses.amazonaws.com"
Action:
- s3:PutObject
Effect: Allow
Sid: "AllowSESPuts"
Resource: "arn:aws:s3:::${ssm:/${self:provider.stage}/lambda/notice-emails/s3/bucket~true}/*"
Condition:
StringEquals:
"aws:Referer": { Ref: AWS::AccountId }
EmailReceiptRule:
Type: AWS::SES::ReceiptRule
DependsOn:
- EmailBucketPermission
Properties:
RuleSetName: ${ssm:/${self:provider.stage}/lambda/notice-emails/ses/ruleSetName~true}
Rule:
Name: ${self:service}-s3
Enabled: true
Recipients:
- ${ssm:/${self:provider.stage}/lambda/notice-emails/ses/recipient~true}
Actions:
- S3Action:
BucketName: ${ssm:/${self:provider.stage}/lambda/notice-emails/s3/bucket~true}
ObjectKeyPrefix: inbound/