-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
86 lines (80 loc) · 2.53 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
service: email-forwarding
frameworkVersion: "2"
provider:
name: aws
runtime: nodejs12.x
memorySize: 512 # optional, in MB, default is 1024
timeout: 10 # optional, in seconds, default is 6
environment: #Shared Environments
NODE_ENV: ${opt:stage}
DESTINATION: ${file(./config/${opt:stage}.json):DESTINATION}
SENDER: ${file(./config/${opt:stage}.json):SENDER}
BUCKET_NAME: ${file(./config/${opt:stage}.json):BUCKET_NAME}-${opt:stage}
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
- s3:DeleteObject
Resource:
- Fn::Join:
- ""
- - Fn::GetAtt: [EmailsBucket, Arn]
- "/*"
- Effect: Allow
Action: ses:SendRawEmail
Resource:
- "*"
functions:
processEmails:
handler: handler.processEmails
resources:
Resources:
GiveSESPermissionToInvokeProcessEmailLambdaFunction:
Type: AWS::Lambda::Permission
Properties:
FunctionName: { "Fn::GetAtt": ["ProcessEmailsLambdaFunction", "Arn"] }
Principal: ses.amazonaws.com
Action: "lambda:InvokeFunction"
SourceAccount: { Ref: AWS::AccountId }
EmailsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${file(./config/${opt:stage}.json):BUCKET_NAME}-${opt:stage}
EmailsBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: { Ref: EmailsBucket }
PolicyDocument:
Statement:
- Action:
- s3:PutObject
Effect: Allow
Resource:
Fn::Join:
- ""
- - { "Fn::GetAtt": ["EmailsBucket", "Arn"] }
- "/*"
Principal:
Service: ses.amazonaws.com
Condition:
StringEquals:
aws:Referer: { Ref: AWS::AccountId }
SesLambdaRule:
Type: AWS::SES::ReceiptRule
DependsOn:
- GiveSESPermissionToInvokeProcessEmailLambdaFunction
- EmailsBucketPolicy
Properties:
Rule:
Enabled: true
ScanEnabled: true
Name: fowarder-email-rule-${opt:stage}
Recipients: ${file(./config/${opt:stage}.json):EMAIL_RECIPIENTS}
Actions:
- LambdaAction:
FunctionArn:
{ "Fn::GetAtt": ["ProcessEmailsLambdaFunction", "Arn"] }
- S3Action:
BucketName: ${file(./config/${opt:stage}.json):BUCKET_NAME}-${opt:stage}
RuleSetName: default-rule-set