-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
template.yaml
89 lines (81 loc) · 2.17 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
thumbnail_creator
SAM Template for thumbnail_creator
Globals:
Function:
Timeout: 180
Parameters:
ImageMagickLayer:
Type: String
Default: "arn:aws:lambda:us-east-1:<account#>:layer:image-magick:1"
GhostscriptLayer:
Type: String
Default: "arn:aws:lambda:us-east-1:<account#>:layer:ghostscript:1"
FfmpegLayer:
Type: String
Default: "arn:aws:lambda:us-east-1:<account#>:layer:ffmpeg:1"
ConversionFileType:
Type: String
Default: jpg
ConversionMimeType:
Type: String
Default: image/jpeg
ThumbnailWidth:
Type: Number
Default: 150
Resources:
UploadBucket:
Type: AWS::S3::Bucket
ResultsBucket:
Type: AWS::S3::Bucket
CreateThumbnail:
Type: AWS::Serverless::Function
Properties:
CodeUri: apps/
Handler: app.lambda_handler
Runtime: python3.8
MemorySize: 2048
Layers:
- !Ref ImageMagickLayer
- !Ref GhostscriptLayer
- !Ref FfmpegLayer
- !Ref FileTypeUtils
Policies:
- S3CrudPolicy:
BucketName: !Sub "${AWS::StackName}-*"
Environment:
Variables:
OUTPUT_BUCKET: !Ref ResultsBucket
EXTENSION: !Sub '.${ConversionFileType}'
MIME_TYPE: !Ref ConversionMimeType
THUMB_WIDTH: !Ref ThumbnailWidth
Events:
FileUpload:
Type: S3
Properties:
Bucket: !Ref UploadBucket
Events: s3:ObjectCreated:*
FileTypeUtils:
Type: AWS::Serverless::LayerVersion
Properties:
Description: FileType package
ContentUri: 'sharedutils/'
CompatibleRuntimes:
- python3.8
Metadata:
BuildMethod: python3.8
Outputs:
CreateThumbnail:
Description: "CreateThumbnail Lambda Function ARN"
Value: !GetAtt CreateThumbnail.Arn
CreateThumbnailIamRole:
Description: "Implicit IAM Role created for CreateThumbnail function"
Value: !GetAtt CreateThumbnailRole.Arn
UploadBucket:
Description: "Upload S3 bucket"
Value: !Ref UploadBucket
ResultsBucket:
Description: "Results S3 bucket"
Value: !Ref ResultsBucket