-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathserverless.yml
67 lines (62 loc) · 1.71 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
service: s3-file-api
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: us-west-1
apiName: ${self:service}
memorySize: 128 # mb
timeout: 10 # seconds
environment:
FILE_UPLOAD_BUCKET_NAME: ${self:custom.fileBucketName}
plugins:
- serverless-iam-roles-per-function
custom:
fileBucketName: s3-file-bucket-${self:provider.stage}
functions:
s3FileUploader:
handler: src/upload.handler
name: s3-file-uploader
description: A lambda handler that uploads a file to an S3 bucket based on an API Gateway trigger.
events:
- http:
path: file
method: POST
iamRoleStatements:
- Effect: Allow
Action:
- "s3:Put*"
Resource: arn:aws:s3:::${self:custom.fileBucketName}/*
s3FileGet:
handler: src/get.handler
name: s3-file-get
description: A lambda handler that retrieves a file from an S3 bucket based on an API Gateway trigger.
events:
- http:
path: file/{fileKey}
method: GET
iamRoleStatements:
- Effect: Allow
Action:
- "s3:Get*"
Resource: arn:aws:s3:::${self:custom.fileBucketName}/*
s3FileDelete:
handler: src/delete.handler
name: s3-file-delete
description: A lambda handler that deletes a file from an S3 bucket based on an API Gateway trigger.
events:
- http:
path: file/{fileKey}
method: DELETE
iamRoleStatements:
- Effect: Allow
Action:
- "s3:DeleteObject"
Resource: arn:aws:s3:::${self:custom.fileBucketName}/*
resources:
Resources:
FileBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.fileBucketName}
AccessControl: Private