Skip to content

Commit

Permalink
Add AWS SAM template and assets
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthSim committed Feb 7, 2024
0 parents commit 9d1e1fb
Show file tree
Hide file tree
Showing 12 changed files with 654 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/lint-and-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint and upload

on:
push:
branches: ["**"]
pull_request:

jobs:
lint-templates:
uses: ./.github/workflows/lint-template.yml
upload-template:
if: github.ref == 'refs/heads/master'
permissions:
contents: read
id-token: write
needs: [lint-templates]
uses: ./.github/workflows/upload-template.yml
with:
tag: latest
secrets: inherit
19 changes: 19 additions & 0 deletions .github/workflows/lint-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint templates

on:
workflow_call:

jobs:
build-and-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dev dependencies
run: pip install cfn-lint
- name: Lint templates
run: cfn-lint template.yml
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
lint-template:
uses: ./.github/workflows/lint-template.yml
upload-template:
permissions:
contents: read
id-token: write
needs: [lint-template]
uses: ./.github/workflows/upload-template.yml
with:
tag: ${{ github.ref_name }}
secrets: inherit
release:
needs: [lint-template, upload-template]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare notes
id: prepare-notes
run: |
# Extract changelog entries between this and previous version headers
escaped_version=$(echo ${GITHUB_REF_NAME#v} | sed -e 's/[]\/$*.^[]/\\&/g')
awk "BEGIN{inrelease=0} /## \[${escaped_version}\]/{inrelease=1;next} /## \[[0-9]+\.[0-9]+\.[0-9]+.*\]/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md \
> RELEASE_NOTES.txt
echo "" >> RELEASE_NOTES.txt
echo "[![](assets/launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=imgproxy&templateURL=https://imgproxy-cf.s3.amazonaws.com/sam/${{ github.ref_name }}/template.yml)" >> RELEASE_NOTES.txt
# Write prerelease="true" env if tag name has any suffix after vMAJOR.MINOR.PATCH
if [[ ${GITHUB_REF_NAME} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
echo 'prerelease="true"' >> $GITHUB_OUTPUT
else
echo 'prerelease="false"' >> $GITHUB_OUTPUT
fi
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_NOTES.txt
prerelease: ${{ fromJSON(steps.prepare-notes.outputs.prerelease) }}
26 changes: 26 additions & 0 deletions .github/workflows/upload-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Templates to S3

on:
workflow_call:
inputs:
tag:
required: true
type: string

jobs:
upload:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
- name: Upload template
run: aws s3 cp template.yml s3://imgproxy-cf/sam/${{ inputs.tag }}/template.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [0.1.0] - 2024-02-07
### Added
- AWS SAM / CloudFormation template for deploying imgproxy to AWS Lambda
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Sergei Aleksandrovich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<p align="center">
<a href="https://imgproxy.net">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg?sanitize=true">
<source media="(prefers-color-scheme: light)" srcset="assets/logo-light.svg?sanitize=true">
<img alt="imgproxy logo" src="assets/logo-light.svg?sanitize=true">
</picture>
</a>
</p>

<h4 align="center">
<a href="https://imgproxy.net">Website</a> |
<a href="https://imgproxy.net/blog/">Blog</a> |
<a href="https://docs.imgproxy.net">Documentation</a> |
<a href="https://imgproxy.net/#pro">imgproxy Pro</a> |
<a href="https://hub.docker.com/r/darthsim/imgproxy/">Docker</a> |
<a href="https://twitter.com/imgproxy_net">Twitter</a> |
<a href="https://discord.gg/5GgpXgtC9u">Discord</a>
</h4>

<p align="center">
<a href="https://github.com/imgproxy/imgproxy-aws-sam/actions"><img alt="GH Lint" src="https://img.shields.io/github/actions/workflow/status/imgproxy/imgproxy-aws-sam/lint-and-upload.yml?branch=master&label=Lint&style=for-the-badge" /></a>
</p>

---

[imgproxy](https://imgproxy.net) is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, speed, and security.

This repository contains an [AWS Serverless Application Model (SAM)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) template compatible with [AWS CloudFormation](https://aws.amazon.com/cloudformation/) that allows you to deploy imgproxy to AWS Lambda.

## Using the template

We uploaded the template to our S3 bucket so you can use by a click of a button. The links below will take you to the AWS CloudFormation console with the template pre-filled. You just need to provide the required parameters and click **Create stack**.

[![](assets/launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=imgproxy&templateURL=https://imgproxy-cf.s3.amazonaws.com/sam/latest/template.yml)

> [!NOTE]
> The link in the README points to the template from the `master` branch. If you want to use a specific version, you can find the links in the [releases](https://github.com/imgproxy/imgproxy-aws-sam/releases) section.
> [!WARNING]
> Official Docker images of imgproxy prior to version `3.22.0` do not contain [AWS Lambda adapter](https://github.com/awslabs/aws-lambda-web-adapter).
>
> If you want to use the template with an older version of imgproxy, you need to build a custom Docker image with the adapter. Take note that this template assumes that the AWS Lambda adapter is configed to work in the `rsponse_stream` mode.
## License

imgproxy-aws-sam is licensed under the MIT license.

See [LICENSE](https://github.com/imgproxy/imgproxy-aws-sam/blob/master/LICENSE) for the full license text.

## Security Contact

To report a security vulnerability, please contact us at [email protected]. We will coordinate the fix and disclosure.
19 changes: 19 additions & 0 deletions assets/launch-stack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions assets/logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions assets/logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9d1e1fb

Please sign in to comment.