Python image compressor using pillow via lambda.
- In project root directory, run script below to install dependency
mkdir libs
pip install --target=./libs -r requirements.txt
- Implement your s3 bucket name inside lambda_function.py.
in lambda_function.py:
BUCKET_NAME = 'TODO'
-
Create AWS IAM role and grant lambda execute, s3 access privileges.
-
Zip whole project, update to lambda console
import boto3
payload = {"TODO": "TODO"}
lambda_client = boto3.client('lambda', aws_access_key_id="TODO", aws_secret_access_key="TODO",
region_name='ap-northeast-2')
lambda_client.invoke(FunctionName='image_compressor', Payload=payload, InvocationType='Event')