-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate.yaml
More file actions
128 lines (121 loc) · 3.37 KB
/
template.yaml
File metadata and controls
128 lines (121 loc) · 3.37 KB
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
122
123
124
125
126
127
128
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Serverless Stellaris save file converter
Parameters:
BucketName:
Type: String
Resources:
FileStorageBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedOrigins:
- "*"
AllowedMethods:
- GET
- POST
LambdaIamRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
- PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "s3:GetObject"
- "s3:PutObject"
Resource: !Join ["", ["arn:aws:s3:::", !Ref BucketName, "/*"]]
PolicyName: stellaris-save-converter
UploadPresignFunction:
Type: AWS::Serverless::Function
DependsOn: LambdaIamRole
Properties:
CodeUri: presign/
Handler: app.upload_lambda_handler
Runtime: python3.6
Role: !GetAtt LambdaIamRole.Arn
Environment:
Variables:
BUCKET_NAME: !Ref BucketName
EXPIRATION: 60
Events:
Upload:
Type: Api
Properties:
Path: /upload
Method: get
DownloadPresignFunction:
Type: AWS::Serverless::Function
DependsOn: LambdaIamRole
Properties:
CodeUri: presign/
Handler: app.download_lambda_handler
Runtime: python3.6
Role: !GetAtt LambdaIamRole.Arn
Environment:
Variables:
BUCKET_NAME: !Ref BucketName
EXPIRATION: 60
Events:
Upload:
Type: Api
Properties:
Path: /download
Method: get
ConverterFunction:
Type: AWS::Serverless::Function
DependsOn: LambdaIamRole
Properties:
CodeUri: converter/
Handler: app.lambda_handler
Runtime: python3.6
Role: !GetAtt LambdaIamRole.Arn
MemorySize: 3008
Timeout: 900
Environment:
Variables:
BUCKET_NAME: !Ref BucketName
Events:
Converter:
Type: S3
Properties:
Bucket: !Ref FileStorageBucket
Events: "s3:ObjectCreated:*"
Filter:
S3Key:
Rules:
- Name: suffix
Value: zip
Outputs:
ApiRoot:
Description: "API Gateway root endpoint"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
FileStorageBucket:
Description: "File S3 Bucket ARN"
Value: !GetAtt FileStorageBucket.Arn
FunctionIamRole:
Description: "IAM role for functions"
Value: !GetAtt LambdaIamRole.Arn
UploadFunction:
Description: "Upload Lambda Function ARN"
Value: !GetAtt UploadPresignFunction.Arn
DownloadFunction:
Description: "Download Lambda Function ARN"
Value: !GetAtt DownloadPresignFunction.Arn
ConverterFunction:
Description: "Converter Lambda Function ARN"
Value: !GetAtt ConverterFunction.Arn