-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
121 lines (115 loc) · 3.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
org: animl
app: animl
service: animl-email-relay
provider:
name: aws
runtime: python3.7
stage: ${opt:stage, 'dev'}
region: us-west-2
profile: animl
iamRoleStatements:
- Effect: 'Allow'
Action:
- 's3:GetObject'
- 's3:ListBucket'
- 's3:DeleteObject'
Resource:
- Fn::Join:
- ''
- - 'arn:aws:s3:::'
- Ref: S3BucketAnimlemailstaging
- Fn::Join:
- ''
- - 'arn:aws:s3:::'
- Ref: S3BucketAnimlemailstaging
- '/*'
- Effect: 'Allow'
Action:
- 's3:PutObject'
Resource:
- Fn::Join:
- ''
- - 'arn:aws:s3:::'
- animl-data-staging-${opt:stage, self:provider.stage, 'dev'}
- Fn::Join:
- ''
- - 'arn:aws:s3:::'
- animl-data-staging-${opt:stage, self:provider.stage, 'dev'}
- '/*'
- Effect: Allow
Action:
- ssm:GetParameter
- ssm:GetParameters
Resource:
- !Sub arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/*
iamManagedPolicies:
- 'arn:aws:iam::aws:policy/AWSLambdaExecute'
environment:
STAGE: ${opt:stage, self:provider.stage, 'dev'}
functions:
RelayImages:
name: RelayImagesLambdaFunction-${opt:stage, self:provider.stage, 'dev'}
handler: src/handler.handler
reservedConcurrency: 10 # max number of lambdas to invoke at one time
events:
- s3:
bucket: animl-email-staging-${opt:stage, self:provider.stage, 'dev'}
event: s3:ObjectCreated:*
existing: true
layers:
- arn:aws:lambda:${self:provider.region}:445285296882:layer:perl-5-26-runtime:12
resources:
Resources:
# Staging bucket
S3BucketAnimlemailstaging:
Type: AWS::S3::Bucket
Properties:
BucketName: animl-email-staging-${opt:stage, self:provider.stage, 'dev'}
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
# Bucket policy for animl-email-staging
S3BucketPolicyAnimlEmailStagingBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: S3BucketAnimlemailstaging
PolicyDocument:
Statement:
-
Action:
- "s3:PutObject"
Effect: "Allow"
Resource:
- "arn:aws:s3:::animl-email-staging-${opt:stage, self:provider.stage, 'dev'}/*"
- "arn:aws:s3:::animl-email-staging-${opt:stage, self:provider.stage, 'dev'}"
Principal:
Service: ses.amazonaws.com
Condition:
StringEquals:
"aws:Referer": { Ref: AWS::AccountId }
# # Lambda Permission grants the bucket permission to invoke the function
# LambdaPermissionAnimlemailstaging:
# Type: AWS::Lambda::Permission
# Properties:
# FunctionName:
# Fn::GetAtt: # grabs function arn
# - relayImagesLambdaFunction
# - Arn
# Principal: s3.amazonaws.com
# Action: lambda:InvokeFunction
# SourceAccount:
# Ref: AWS::AccountId
# SourceArn: arn:aws:s3:::animl-email-staging-${opt:stage, self:provider.stage, 'dev'}
custom:
pythonRequirements:
dockerizePip: non-linux
dockerFile: Dockerfile
useDownloadCache: false
useStaticCache: false
dockerExtraFiles:
- -r /output/exiftool/
plugins:
- serverless-python-requirements