Serverless Image Handler
Serverless Image Handler

Appendix J: Customizing Thumbor Lambda package

Use the following procedure to make customizations to the Thumbor Lambda package:

Note that you must create two publicly accessible Amazon S3 buckets: my-bucket-name, and my-bucket-name-<aws-region>.

  1. Configure the bucket name to your Amazon S3 distribution bucket.

    export TEMPLATE_OUTPUT_BUCKET=my-bucket-name # bucket where cfn template will reside export DIST_OUTPUT_BUCKET=my-bucket-name # bucket where customized code will reside export VERSION=my-version # version number for the customized code
  2. Setup your OS/Python Environment:

    $ yum install yum-utils epel-release -y $ sudo yum-config-manager --enable epel $ sudo yum update -y $ sudo yum install zip wget git libpng-devel libcurl-devel gcc python-devel libjpeg-devel -y $ alias sudo='sudo env PATH=$PATH' $ sudo pip install setuptools==39.0.1 $ sudo pip install virtualenv==15.2.0
  3. Clone the github repo:

    $ git clone https://github.com/awslabs/serverless-image-handler.git
  4. Navigate to the deployment folder:

    $ cd serverless-image-handler/deployment
  5. Run ./build-s3-dist.sh <bucket-name> <version>:

    $ ./build-s3-dist.sh mybucket v1.0

    Note that the <bucket-name> should be the name for the Amazon S3 bucket location where the template will source the Lambda code. The template will append -[region_name] as the value. In the above example, the solution template will expect the source code to be located in the mybucket-[region_name] bucket: serverless-image-handler/v1.0/serverless-image-handler.zip

  6. Deploy the distribution to an Amazon S3 bucket in your account. Note that you must have AWS Command Line Interface installed.

    bash aws s3 cp ./dist/ s3://$DIST_OUTPUT_BUCKET-[region_name]/serverless-image-handler/$VERSION/ --recursive --exclude "*" --include "*.zip" aws s3 cp ./dist/serverless-image-handler.template s3://$TEMPLATE_OUTPUT_BUCKET/serverless-image-handler/$VERSION/

    Note that the solution will verify the source code is located in the my-bucket-name-[region-name] bucket with the prefix: serverless-image-handler/my-version/serverless-image-handler.zip

  7. Copy the serverless-image-handler.template link uploaded to your Amazon S3 bucket.

  8. Using the copied link above, deploy the Serverless Image Handler into your account.

    ```bash https://s3.amazonaws.com/my-bucket-name/serverless-image-handler/my-version/serverless-image-handler.template ```