Serverless Image Handler
Serverless Image Handler

Appendix E: Image Handler Function Environmental Variables

Most settings and customizations to the Serverless Image Handler solution can be made by editing and updating the environment variables associated with the image handler AWS Lambda function.

The image handler function can be found in the AWS Management Console using one of the following methods:

  • In the Lambda Management Console, the image handler function is listed with the following naming convention: <StackName>-<ImageHandlerFunction>-<UniqueId> .

  • In the AWS CloudFormation Management Console, the image handler function is listed under the Resources tab of your deployed stack with a Logical ID of ImageHandlerFunction.

After opening the Lambda function, scroll down to the Environment variables section. Use the following key-value pairs to customize the solutions settings:

Parameter Default Description
CorsEnabled Yes/No Indicates whether to return an Access-Control-Allow-Origin header with the image handler API response.
CorsOrigin String This value is returned by the API in the Access-Control-Allow-Origin header. A star (*) value supports any origin. We recommend specifying a specific origin (e.g. http://example.domain) to restrict cross-site access to your API.

Note

This value is ignored if CorsEnabled is set to No.

RewriteMatchPattern Regex By default, this parameter is empty. Contains a JavaScript-compatible regular expression for matching custom image requests using the rewrite function.
RewriteReplacePattern String By default, this parameter is empty. Contains a substitution string for custom image requests using the rewrite function.
SourceBuckets String The S3 bucket (or buckets) in your account that contains the original images. If providing multiple buckets, separate them by commas.