https://github.com/cuppilekkia/image-lambda-function
https://github.com/cuppilekkia/image-lambda-function
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cuppilekkia/image-lambda-function
- Owner: cuppilekkia
- Created: 2020-01-03T19:03:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T14:29:27.000Z (almost 2 years ago)
- Last Synced: 2025-02-02T09:33:22.745Z (4 months ago)
- Language: JavaScript
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**Image Resize service**
---Services:
--
- Lambda function
- API GatewayThis service requires an S3 Bucket as a source of images, set as Static Hosting, with the following
bucket policy:
-
```
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET_NAME/*"
}
]
}
```redirect rule:
-
```
404
https
API_GATEWAY_HOSTNAME
prod/resize?key=
307
```
ENV variables for BUCKET_NAME and URL are currently saved in the `function-template.yaml`
---
The image is requested in the folder on S3 that contains the resized copy like:`path-to-image/s200x100/image.[jpg|webp]`
The original image must be in the parent folder like:
`path-to-image/image.jpg`
--
The 'resize' folder can have the following pattern:
- **s**200x100 (resize and crop with provided width and height)
- **w**200 (resize to provided width, keep ratio)
- **h**200 (resize to provided height, keep ratio)--
Provess:
The file is requested to S3, when that size is not available the request gets redirected to the API gateway which fires the lambda function associated to perform the resize/crop/format on the original image.
*If a WEBP format is requested, the file will be generated always from the original JPG version and saved for further requests.*
Then the new file is saved in the correct folder into the S3 bucket itself and returned to the user.
---
TODO:
-
- Complete the docs including the process to package/deploy the stack
- Build a pipeline to CI/CD