forked from cagataygurturk/image-resizer-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
117 lines (117 loc) · 2.58 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
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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: Serverless REST API for image resizing
Parameters:
ImageBucket:
Type: String
Description: S3 Bucket where original images are placed
MemorySize:
Type: Number
Default: 3008
Description: Memory size to be used for your Lambda (Note that this setting will increase also the CPU power and price per second.)
AllowedValues:
- 128
- 192
- 256
- 320
- 384
- 448
- 512
- 576
- 640
- 704
- 768
- 832
- 896
- 960
- 1024
- 1088
- 1152
- 1216
- 1280
- 1344
- 1408
- 1472
- 1536
- 1600
- 1664
- 1728
- 1792
- 1856
- 1920
- 1984
- 2048
- 2112
- 2176
- 2240
- 2304
- 2368
- 2432
- 2496
- 2560
- 2624
- 2688
- 2752
- 2816
- 2880
- 2944
- 3008
Resources:
ResizeFunctionImagemagickLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: image-magick
Description: Static build of ImageMagick for AWS Linux 2
ContentUri: dependencies/
CompatibleRuntimes:
- nodejs10.x
- nodejs12.x
- python3.8
LicenseInfo: https://imagemagick.org/script/license.php
RetentionPolicy: Retain
ResizeFunction:
Type: AWS::Serverless::Function
Properties:
Description: Image Resizing Lambda
Handler: index.handler
Runtime: nodejs12.x
Layers:
- arn:aws:lambda:eu-west-1:472473066617:layer:image-magick:1
Timeout: 60
CodeUri: dist/bundle.zip
MemorySize: !Ref MemorySize
Policies:
- S3ReadPolicy:
BucketName:
Ref: ImageBucket
Events:
AuthorizerApiRoot:
Properties:
Method: GET
Path: '/{proxy+}'
RestApiId: !Ref Api
Type: Api
Environment:
Variables:
IMAGE_BUCKET:
Ref: ImageBucket
Api:
Type: AWS::Serverless::Api
Properties:
Name: ImageResizerAPI
StageName: production
DefinitionBody:
swagger: "2.0"
schemes:
- "https"
paths:
'/{proxy+}':
get:
responses: {}
x-amazon-apigateway-integration:
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ResizeFunction.Arn}/invocations
passthroughBehavior: "when_no_match"
httpMethod: "POST"
type: aws_proxy
x-amazon-apigateway-binary-media-types:
- "*/*"