-
Notifications
You must be signed in to change notification settings - Fork 19
/
template.yaml
65 lines (61 loc) · 1.86 KB
/
template.yaml
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Serverless S3 Uploader - upload files to S3 buckets from your web applications using pre-signed URLs.
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Api:
# Allows any site to call these APIs (can restrict by replacing asterisk with site name)
# Automatically adds AllowMethods with a list of methods for this API
EndpointConfiguration: EDGE
Cors:
AllowMethods: "'OPTIONS,GET'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
Function:
Timeout: 5
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- GET
- PUT
- POST
- DELETE
- HEAD
AllowedOrigins:
- "*"
S3UploaderFunction:
# More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Type: AWS::Serverless::Function
Properties:
CodeUri: s3UploaderFunction/
Handler: app.handler
Runtime: nodejs12.x
MemorySize: 128
Environment:
Variables:
UploadBucket: !Ref S3Bucket
Policies:
- S3CrudPolicy:
BucketName: !Ref S3Bucket
Events:
HttpPost:
Type: Api
Properties:
Path: '/'
Method: get
Outputs:
S3UploaderFunction:
Description: "Lambda Function ARN"
Value: !GetAtt S3UploaderFunction.Arn
S3UploaderFunctionIamRole:
Description: "Implicit IAM Role created for function"
Value: !GetAtt S3UploaderFunctionRole.Arn
S3BucketName:
Description: S3 bucket
Value: !Ref S3Bucket