- develop in
source/image-handler/...
- create .zip file to upload to Lambda by running:
cd deployment/; sudo ./build-s3-dist.sh
- find the file in
deployment/dist/image-handler.zip
Longer version:
- Clone the repository, then make the desired code changes
- Next, run unit tests to make sure added customization passes the tests
cd ./deployment
chmod +x ./run-unit-tests.sh \n
./run-unit-tests.sh \n
- Configure the bucket name of your target 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
Note: You would have to create 2 buckets, one named 'my-bucket-name' and another regional bucket named 'my-bucket-name-<aws_region>'; aws_region is where you are testing the customized solution. Also, the assets in bucket should be publicly accessible.
* Clone the github repo
```bash
git clone https://github.com/awslabs/serverless-image-handler.git
- Navigate to the deployment folder
cd serverless-image-handler/deployment
- Now build the distributable
sudo ./build-s3-dist.sh $DIST_OUTPUT_BUCKET $VERSION
- Deploy the distributable to an Amazon S3 bucket in your account. Note: you must have the AWS Command Line Interface installed.
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: In the above example, the solution template will expect the source code to be located in the my-bucket-name-[region_name] with prefix serverless-image-handler/my-version/serverless-image-handler.zip
- Get the link of the serverless-image-handler.template uploaded to your Amazon S3 bucket.
- Deploy the Serverless Image Handler solution to your account by launching a new AWS CloudFormation stack using the link of the serverless-image-handler.template
https://s3.amazonaws.com/my-bucket-name/serverless-image-handler/my-version/serverless-image-handler.template
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/asl/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License.
-
install docker
-
install AWS CLI and configure the credentials
-
sam build --use-container && sam local start-api --log-file ./local.log
(use-container is required for using the npm module sharp within a docker container). Rerun whenever you change the template.yaml -
run
tail -f local.log
in parallel -
changes will not be reflected automatically in the source fold, but in the
.aws-sam
folder, because we have to use sam build -
in order to debug, use
=> once require('sharp')
is executed, it crashes without any error. Probably because if a wrongfully installed compiled version of sharp -> leading to a timeout!