-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
75 lines (68 loc) · 2.07 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
service: aws-java-simple-http-endpoint
frameworkVersion: ">=1.2.0 <2.0.0"
plugins:
- serverless-apigw-binary
custom:
bucketName: "s3-proxy-tutorial-destination"
tableName: "s3-proxy-tutorial-metadata"
apigwBinary:
types: #list of mime-types
- '*/*'
provider:
name: aws
region: us-east-2
runtime: java11
iamRoleStatements: # permissions for all of your functions can be set here
- Effect: Allow
Action: # Gives permission to S3 bucket
- s3:ListBucket
Resource: { 'Fn::Join': ['', ['arn:aws:s3:::', { 'Ref': 'storageBucket' }]] }
- Effect: Allow
Action: # Gives permission to S3 bucket
- s3:PutObject
Resource : { 'Fn::Join': ['', ['arn:aws:s3:::', { 'Ref': 'storageBucket' }, '/*']] }
- Effect: Allow
Action: # Gives permission to dynamo tables in a specific region
- dynamodb:PutItem
Resource: { 'Fn::Join': ['', ['arn:aws:dynamodb:', { Ref: 'AWS::Region' }, ':', { Ref: 'AWS::AccountId' }, ':table/', { 'Ref': 'metadataTable' }]] }
package:
artifact: build/libs/s3-proxy-all.jar
functions:
s3-proxy:
handler: com.bcchapman.Handler
environment:
BUCKET_NAME: { 'Ref': 'storageBucket' }
TABLE_NAME: { 'Ref': 'metadataTable' }
events:
- http:
path: createFile
method: post
request:
parameters:
querystrings:
filePath: true
resources:
Resources:
storageBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.bucketName}
metadataTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: user
AttributeType: S
- AttributeName: path
AttributeType: S
KeySchema:
- AttributeName: user
KeyType: HASH
- AttributeName: path
KeyType: RANGE
BillingMode:
PAY_PER_REQUEST
ProvisionedThroughput:
ReadCapacityUnits: 0
WriteCapacityUnits: 0
TableName: ${self:custom.tableName}