Simple image resize AWS lambda function
Simple AWS lambda serverless function for resizing images. The function resizes the image based on input parameters for size and upload the image on AWS S3.
Run the following commands
$ npm install -g serverless # Install serverless globally
$ serverless config credentials --provider aws --key <AWS Access Key ID> --secret <AWS Secret Access Key> # Setting up default aws credentials
$ cd aws-serverless-image-resize
$ npm install # Installing dependency
$ serverless deploy # Deploying serverless function to aws
By this command serverless deploy
you should be able to see the lambda function in your aws lambda dashboard and it should have returned an endpoint and api_key in your terminal keep these for now.
Setup the following variables into your aws lambda function
Run export MY_API_KEY=<any random key value for your lambda function>
Make a GET API call with to the endpoint and send x-api-key into headers with the api_key value returned after deploy command. The API supports the following query parameters
<API_URL>?imageUrl=https://s3.amazonaws.com/towlot-portal-images/1551975541895.jpeg&height=200
The API call will return the image URL that has been added to your S3 account.
Built under MIT license.