Skip to content

Commit 0d1adf9

Browse files
committed
imgproxy template
0 parents  commit 0d1adf9

9 files changed

Lines changed: 1364 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tmp/

ecs-ec2.yml

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: imgproxy running in ECS
3+
4+
Parameters:
5+
ClusterInstanceType:
6+
Description: EC2 instance type to use in your ECS cluster
7+
Type: String
8+
Default: c7g.large
9+
AllowedValues:
10+
- 'c7g.medium'
11+
- 'c7g.large'
12+
- 'c7g.xlarge'
13+
- 'c7g.2xlarge'
14+
- 'c7g.4xlarge'
15+
- 'c7g.8xlarge'
16+
- 'c7g.12xlarge'
17+
- 'c7g.16xlarge'
18+
- 't4g.small'
19+
- 't4g.medium'
20+
- 't4g.large'
21+
- 't4g.xlarge'
22+
- 't4g.2xlarge'
23+
24+
ClusterDeisedSize:
25+
Type: Number
26+
Description: Number of EC2 instances to initially launch in your ECS cluster
27+
Default: 1
28+
MinValue: 1
29+
30+
ClusterMaxSize:
31+
Type: Number
32+
Description: The maximum number of EC2 instances to launch in your ECS cluster
33+
Default: 5
34+
MinValue: 1
35+
36+
DockerImage:
37+
Type: String
38+
Description: >
39+
The imgproxy or imgproxy Pro Docker image name stored in a public registry
40+
or your ECR registry.
41+
Use Docker images built for the ARM64 (aarch64) platform
42+
Default: 'darthsim/imgproxy:latest-arm64'
43+
44+
EnvironmentFile:
45+
Type: String
46+
Description: >
47+
ARN of the Amazon S3 object containing the environment variable file.
48+
The file must have a .env file extension.
49+
Each line in an environment file should contain an environment variable in VARIABLE=VALUE format.
50+
Lines beginning with # are treated as comments and are ignored.
51+
See https://docs.imgproxy.net/configuration for supported environment variables
52+
Default: ''
53+
54+
ContainerCpu:
55+
Type: Number
56+
Description: Amount of CPU to give to the container? 1024 is 1 CPU
57+
Default: 1024
58+
MinValue: 1024
59+
60+
ContainerMemory:
61+
Type: Number
62+
Description: Amount of memory in megabytes to give to the container
63+
Default: 1024
64+
MinValue: 512
65+
66+
TaskDesiredCount:
67+
Type: Number
68+
Description: Number of imgproxy instances to initially launch in your service
69+
Default: 2
70+
MinValue: 1
71+
72+
TaskMaxCount:
73+
Type: Number
74+
Description: Maximum number of imgproxy instances we can launch in your service
75+
Default: 8
76+
77+
PathPrefix:
78+
Type: String
79+
Description: >
80+
Path prefix, beginning with a slash (/).
81+
Do not add a slash (/) at the end of the path
82+
Default: ''
83+
84+
CreateCloudForontDistribution:
85+
Type: String
86+
Description: >
87+
Should caching CloudFront distribution be created?
88+
This CloudFront distribution will automatically add the path prefix when requesting the origin.
89+
Also, it will automatically add X-Imgproxy-Auth header with the provided authorization token
90+
Default: 'Yes'
91+
AllowedValues:
92+
- 'Yes'
93+
- 'No'
94+
95+
AuthorizationToken:
96+
Type: String
97+
Description: >
98+
The authorization token that should be provided via the X-Imgproxy-Auth header to
99+
get access to imgproxy. Allows to prevent access to imgproxy bypassing CDN.
100+
The X-Imgproxy-Auth header will be checked by the load balancer listener rule
101+
Default: ''
102+
103+
S3Objects:
104+
Type: CommaDelimitedList
105+
Description: >
106+
ARNs of S3 objects (comma delimited) that imgproxy should have access to.
107+
You can grant access to multiple objects with a single ARN by using wildcards.
108+
Example: arn:aws:s3:::my-images-bucket/*,arn:aws:s3:::my-assets-bucket/images/*
109+
Default: ''
110+
111+
Metadata:
112+
AWS::CloudFormation::Interface:
113+
ParameterGroups:
114+
- Label:
115+
default: "Cluster Configuration"
116+
Parameters:
117+
- ClusterInstanceType
118+
- ClusterDeisedSize
119+
- ClusterMaxSize
120+
- Label:
121+
default: "Service Configuration"
122+
Parameters:
123+
- DockerImage
124+
- EnvironmentFile
125+
- ContainerCpu
126+
- ContainerMemory
127+
- TaskDesiredCount
128+
- TaskMaxCount
129+
- Label:
130+
default: "Endpoint Configuration"
131+
Parameters:
132+
- PathPrefix
133+
- CreateCloudForontDistribution
134+
- Label:
135+
default: "Security"
136+
Parameters:
137+
- AuthorizationToken
138+
- S3Objects
139+
140+
ParameterLabels:
141+
ClusterInstanceType:
142+
default: "EC2 Instance Type"
143+
ClusterDeisedSize:
144+
default: "Desired Number Of instances"
145+
ClusterMaxSize:
146+
default: "Maximum Number Of instances"
147+
DockerImage:
148+
default: "Docker image"
149+
EnvironmentFile:
150+
default: "Environment file"
151+
ContainerCpu:
152+
default: "CPU Per Task"
153+
ContainerMemory:
154+
default: "Memory Per Task"
155+
TaskDesiredCount:
156+
default: "Desired Number Of Tasks"
157+
TaskMaxCount:
158+
default: "Maximum Number Of Tasks"
159+
PathPrefix:
160+
default: "Path Prefix (optional)"
161+
CreateCloudForontDistribution:
162+
default: "Create CloudForont Distribution?"
163+
AuthorizationToken:
164+
default: "Authorization Token (optional)"
165+
S3Objects:
166+
default: "S3 Objects (optional)"
167+
168+
Conditions:
169+
DeployCloudFront: !Equals [!Ref 'CreateCloudForontDistribution', 'Yes']
170+
171+
Resources:
172+
Network:
173+
Type: AWS::CloudFormation::Stack
174+
Properties:
175+
TemplateURL: https://s3.amazonaws.com/imgproxy-cloudformation/templates/network.yml
176+
Parameters:
177+
EnvironmentName: !Ref AWS::StackName
178+
179+
ALB:
180+
Type: AWS::CloudFormation::Stack
181+
Properties:
182+
TemplateURL: https://s3.amazonaws.com/imgproxy-cloudformation/templates/load-balancer.yml
183+
Parameters:
184+
EnvironmentName: !Ref AWS::StackName
185+
VPC: !GetAtt Network.Outputs.VPC
186+
Subnets: !GetAtt Network.Outputs.PublicSubnets
187+
SecurityGroup: !GetAtt Network.Outputs.LoadBalancerSecurityGroup
188+
189+
Cluster:
190+
Type: AWS::CloudFormation::Stack
191+
Properties:
192+
TemplateURL: https://s3.amazonaws.com/imgproxy-cloudformation/templates/ecs-cluster.yml
193+
Parameters:
194+
EnvironmentName: !Ref AWS::StackName
195+
196+
CapacityProvider:
197+
Type: AWS::CloudFormation::Stack
198+
Properties:
199+
TemplateURL: https://s3.amazonaws.com/imgproxy-cloudformation/templates/ecs-capacity-provider.yml
200+
Parameters:
201+
EnvironmentName: !Ref AWS::StackName
202+
Cluster: !GetAtt Cluster.Outputs.Cluster
203+
VPC: !GetAtt Network.Outputs.VPC
204+
SecurityGroup: !GetAtt Network.Outputs.ECSHostSecurityGroup
205+
Subnets: !GetAtt Network.Outputs.PublicSubnets
206+
ClusterInstanceType: !Ref ClusterInstanceType
207+
ClusterDeisedSize: !Ref ClusterDeisedSize
208+
ClusterMaxSize: !Ref ClusterMaxSize
209+
210+
Service:
211+
Type: AWS::CloudFormation::Stack
212+
Properties:
213+
TemplateURL: https://s3.amazonaws.com/imgproxy-cloudformation/templates/ecs-service.yml
214+
Parameters:
215+
EnvironmentName: !Ref AWS::StackName
216+
VPC: !GetAtt Network.Outputs.VPC
217+
SecurityGroup: !GetAtt Network.Outputs.ECSHostSecurityGroup
218+
Subnets: !GetAtt Network.Outputs.PublicSubnets
219+
Cluster: !GetAtt Cluster.Outputs.Cluster
220+
CapacityProvider: !GetAtt CapacityProvider.Outputs.CapacityProvider
221+
Listener: !GetAtt ALB.Outputs.Listener
222+
LaunchType: EC2
223+
DockerImage: !Ref DockerImage
224+
EnvironmentFile: !Ref EnvironmentFile
225+
ContainerCpu: !Ref ContainerCpu
226+
ContainerMemory: !Ref ContainerMemory
227+
TaskDesiredCount: !Ref TaskDesiredCount
228+
TaskMaxCount: !Ref TaskMaxCount
229+
PathPrefix: !Ref PathPrefix
230+
AuthorizationToken: !Ref AuthorizationToken
231+
S3Objects: !Join [ ",", !Ref S3Objects ]
232+
233+
CloudFront:
234+
Condition: DeployCloudFront
235+
Type: AWS::CloudFormation::Stack
236+
Properties:
237+
TemplateURL: https://s3.amazonaws.com/imgproxy-cloudformation/templates/cloudfront.yml
238+
Parameters:
239+
EnvironmentName: !Ref AWS::StackName
240+
OriginHost: !GetAtt ALB.Outputs.LoadBalancerUrl
241+
AuthorizationToken: !Ref AuthorizationToken
242+
PathPrefix: !Ref PathPrefix
243+
244+
Outputs:
245+
DirectURL:
246+
Description: The direct URL endpoint for imgproxy
247+
Value: !GetAtt ALB.Outputs.LoadBalancerUrl
248+
249+
CloudFrontURL:
250+
Condition: DeployCloudFront
251+
Description: The CloudFront endpoint for imgproxy
252+
Value: !GetAtt CloudFront.Outputs.CloudFrontURL

0 commit comments

Comments
 (0)