Skip to content

Latest commit

 

History

History

insecure

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Insecure mode

Minimal imgproxy on AWS Lambda with no request signing (insecure = true): community edition, default sizing, a public Function URL, no monitoring and no S3. It fetches public placeholder images.

Warning

This example is intended for development and testing only. Without request signing anyone can use your imgproxy (unlimited bandwidth costs, no protection against abuse, no control over processed images). Never use this configuration in production.

AWS setup

You need an AWS account, the AWS CLI, authenticated, and Docker (to push the imgproxy image into ECR, because Lambda only runs ECR images):

aws configure
# or: aws sso login --profile my-profile && export AWS_PROFILE=my-profile

Note

Commands use --profile $PROFILE_NAME; drop the flag to use default credentials. A GetRoleCredentials ... No access error means the profile is missing or wrong.

Prerequisites

PROFILE_NAME=my-profile # AWS CLI profile used by Terraform; see AWS setup
REGION=us-east-1

Deploy

echo "region = \"$REGION\"" > terraform.tfvars
echo "profile = \"$PROFILE_NAME\"" >> terraform.tfvars # AWS CLI profile used by Terraform; omit for default credentials

terraform init

# 1. Create the ECR repository (Lambda runs ECR images only; the module does not create it)
terraform apply -target=aws_ecr_repository.imgproxy

# 2. Push the image to it. The -arm64 tag is the single-platform build for Graviton, the default architecture
REPO_URL=$(terraform output -raw repository_url)
aws ecr get-login-password --profile $PROFILE_NAME --region $REGION | docker login --username AWS --password-stdin "${REPO_URL%%/*}"
docker pull ghcr.io/imgproxy/imgproxy:v4-arm64
docker tag ghcr.io/imgproxy/imgproxy:v4-arm64 "$REPO_URL:v4"
docker push "$REPO_URL:v4"

# 3. Deploy the function
terraform plan
terraform apply

Terraform creates the function, which takes a minute. Then print a ready-to-open URL (paste it into a browser; no signature is required in insecure mode):

echo "$(terraform output -raw url)/insecure/rs:fit:300:300/plain/https://picsum.photos/1200/800.jpg"

The first request after a deploy (or after idle time) starts a new function instance, which takes a few seconds; later requests are fast. provisioned_concurrency keeps instances warm: see complete.

Cleanup

terraform destroy

Next

Continue with signed.