forked from aws-solutions/serverless-image-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from awslabs/master
Updated to Version 4.1.
- Loading branch information
Showing
25 changed files
with
1,409 additions
and
1,042 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# compiled output | ||
**/dist | ||
**/global-s3-assets | ||
**/regional-s3-assets | ||
**/open-source | ||
**/.zip | ||
**/tmp | ||
**/out-tsc | ||
|
||
# dependencies | ||
**/node_modules | ||
|
||
# test assets | ||
**/coverage | ||
**/.nyc_output | ||
|
||
# misc | ||
**/npm-debug.log | ||
**/testem.log | ||
**/package-lock.json | ||
**/.vscode/settings.json | ||
demo-ui-config.js | ||
|
||
# System Files | ||
**/.DS_Store | ||
**/.DS_Store | ||
**/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [4.1] - 2019-12-31 | ||
### Added | ||
- CHANGELOG file | ||
- Access logging to API Gateway | ||
|
||
### Changed | ||
- Lambda functions runtime to nodejs12.x | ||
- sharp version (from 0.21.3 to 0.23.3) | ||
- Image handler function to use Composite API (https://sharp.pixelplumbing.com/en/stable/api-composite/) | ||
- License to Apache-2.0 | ||
|
||
# Removed | ||
- Reference to deprecated sharp function (overlayWith) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
# Contributing Guidelines | ||
|
||
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional | ||
documentation, we greatly value feedback and contributions from our community. | ||
|
||
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary | ||
information to effectively respond to your bug report or contribution. | ||
|
||
|
||
## Reporting Bugs/Feature Requests | ||
|
||
We welcome you to use the GitHub issue tracker to report bugs or suggest features. | ||
|
||
When filing an issue, please check [existing open](https://github.com/awslabs/serverless-image-handler/issues), or [recently closed](https://github.com/awslabs/serverless-image-handler/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already | ||
|
@@ -19,7 +16,6 @@ reported the issue. Please try to include as much information as you can. Detail | |
* Any modifications you've made relevant to the bug | ||
* Anything unusual about your environment or deployment | ||
|
||
|
||
## Contributing via Pull Requests | ||
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: | ||
|
||
|
@@ -39,23 +35,17 @@ To send us a pull request, please: | |
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and | ||
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/). | ||
|
||
|
||
## Finding contributions to work on | ||
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/serverless-image-handler/labels/help%20wanted) issues is a great place to start. | ||
|
||
|
||
## Code of Conduct | ||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). | ||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact | ||
[email protected] with any additional questions or comments. | ||
|
||
|
||
## Security issue notifications | ||
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. | ||
|
||
|
||
## Licensing | ||
|
||
See the [LICENSE](https://github.com/awslabs/serverless-image-handler/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. | ||
|
||
See the [LICENSE](https://github.com/awslabs/serverless-image-handler/blob/master/LICENSE.txt) file for our project's licensing. We will ask you to confirm the licensing of your contribution. | ||
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
Serverless Image Handler | ||
|
||
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. | ||
|
||
********************** | ||
THIRD PARTY COMPONENTS | ||
********************** | ||
This software includes third party software subject to the following copyrights: | ||
|
||
AWS SDK under the Apache License Version 2.0 | ||
uuid under the Massachusetts Institute of Technology (MIT) license | ||
sharp under the Apache License Version 2.0 | ||
sinon under the BSD 3-Clause license | ||
aws-sdk under the Apache License Version 2.0 | ||
aws-sdk-mock under the Apache License Version 2.0 | ||
Bootstrap under the Massachusetts Institute of Technology (MIT) license | ||
chai under the Massachusetts Institute of Technology (MIT) license | ||
sinon-chai under the BSD 2-Clause license | ||
minimist under the Massachusetts Institute of Technology (MIT) license | ||
mocha under the Massachusetts Institute of Technology (MIT) license | ||
moment under the Massachusetts Institute of Technology (MIT) license | ||
npm-run-all under the Massachusetts Institute of Technology (MIT) license | ||
nyc under the ISC license | ||
|
||
The licenses for these third party components are included in LICENSE.txt | ||
sharp under the Apache License Version 2.0 | ||
sinon under the BSD-3-Clause license | ||
sinon-chai under the BSD-2-Clause license | ||
uuid under the Massachusetts Institute of Technology (MIT) license |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,59 @@ | ||
**_Important Notice:_** | ||
Due to a [change in the AWS Lambda execution environment](https://aws.amazon.com/blogs/compute/upcoming-updates-to-the-aws-lambda-execution-environment/), Serverless Image Handler v3 deployments are functionally broken. To address the issue we have released [minor version update v3.1.1](https://solutions-reference.s3.amazonaws.com/serverless-image-handler/v3.1.1/serverless-image-handler.template). We recommend all users of v3 to run cloudformation stack update with v3.1.1. Additionally, we suggest you to look at v4 of the solution and migrate to v4 if it addresses all of your use cases. | ||
Due to a [change in the AWS Lambda execution environment](https://aws.amazon.com/blogs/compute/upcoming-updates-to-the-aws-lambda-execution-environment/), Serverless Image Handler v3 deployments are functionally broken. To address the issue we have released [minor version update v3.1.1](https://solutions-reference.s3.amazonaws.com/serverless-image-handler/v3.1.1/serverless-image-handler.template). We recommend all users of v3 to run cloudformation stack update with v3.1.1. Additionally, we suggest you to look at v4 of the solution and migrate to v4 if it addresses all of your use cases. | ||
|
||
# AWS Serverless Image Handler Lambda wrapper for SharpJS | ||
A solution to dynamically handle images on the fly, utilizing Sharp (https://sharp.pixelplumbing.com/en/stable/). | ||
Published version, additional details and documentation are available here: https://aws.amazon.com/solutions/serverless-image-handler/ | ||
|
||
_Note:_ it is recommend to build the application binary on Amazon Linux. | ||
|
||
## Running unit tests for customization | ||
## Building distributable for customization | ||
* 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 | ||
```bash | ||
git clone https://github.com/awslabs/serverless-image-handler.git | ||
``` | ||
|
||
## Building distributable for customization | ||
* Configure the bucket name of your target Amazon S3 distribution bucket | ||
* Run unit tests to make sure added customization passes the tests: | ||
``` | ||
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 | ||
cd ./deployment | ||
chmod +x ./run-unit-tests.sh | ||
./run-unit-tests.sh | ||
``` | ||
_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. | ||
|
||
* Create an Amazon S3 Bucket | ||
``` | ||
* Clone the github repo | ||
```bash | ||
git clone https://github.com/awslabs/serverless-image-handler.git | ||
aws s3 mb s3://my-bucket-us-east-1 --region us-east-1 | ||
``` | ||
|
||
* Navigate to the deployment folder | ||
* Navigate to the deployment folder and build the distributable | ||
```bash | ||
cd serverless-image-handler/deployment | ||
chmod +x ./build-s3-dist.sh | ||
./build-s3-dist.sh my-bucket serverless-image-handler my-version | ||
``` | ||
|
||
* Now build the distributable | ||
```bash | ||
sudo ./build-s3-dist.sh $DIST_OUTPUT_BUCKET $VERSION | ||
``` | ||
> Note: The build-s3-dist script expects the bucket name as one of its parameters, and this value should not include the region suffix. | ||
* Deploy the distributable to an Amazon S3 bucket in your account. Note: you must have the AWS Command Line Interface installed. | ||
* Deploy the distributable to an Amazon S3 bucket in your account (you must have the AWS CLI 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/ | ||
aws s3 cp ./regional-s3-assets/ s3://my-bucket-us-east-1/serverless-image-handler/my-version/ --recursive --acl bucket-owner-full-control | ||
``` | ||
_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. | ||
* 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 | ||
```bash | ||
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 | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://aws.amazon.com/asl/ | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
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. | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,88 @@ | ||
#!/bin/bash | ||
# | ||
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned | ||
# | ||
# This script should be run from the repo's deployment directory | ||
# cd deployment | ||
# ./build-s3-dist.sh source-bucket-base-name trademarked-solution-name version-code | ||
# | ||
# Paramenters: | ||
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda | ||
# code from. The template will append '-[region_name]' to this bucket name. | ||
# For example: ./build-s3-dist.sh solutions my-solution v1.0.0 | ||
# The template will then expect the source code to be located in the solutions-[region_name] bucket | ||
# | ||
# - trademarked-solution-name: name of the solution for consistency | ||
# | ||
# - version-code: version of the package | ||
|
||
# Check to see if input has been provided: | ||
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then | ||
echo "Please provide the base source bucket name, trademark approved solution name and version where the lambda code will eventually reside." | ||
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.0" | ||
exit 1 | ||
fi | ||
|
||
set -e | ||
|
||
# Get reference for all important folders | ||
template_dir="$PWD" | ||
template_dist_dir="$template_dir/global-s3-assets" | ||
build_dist_dir="$template_dir/regional-s3-assets" | ||
source_dir="$template_dir/../source" | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Setup the dist folder" | ||
echo "Rebuild distribution" | ||
echo "------------------------------------------------------------------------------" | ||
rm -r dist | ||
mkdir dist | ||
cd dist | ||
mkdir demo-ui | ||
cd .. | ||
rm -rf $template_dist_dir | ||
mkdir -p $template_dist_dir | ||
rm -rf $build_dist_dir | ||
mkdir -p $build_dist_dir | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Copy in the template" | ||
echo "CloudFormation Template" | ||
echo "------------------------------------------------------------------------------" | ||
cp *.template dist/ | ||
|
||
replace="s/%%BUCKET_NAME%%/$1/g" | ||
sed -i '' -e $replace dist/*.template | ||
|
||
replace="s/%%TEMPLATE_BUCKET%%/$2/g" | ||
sed -i '' -e $replace dist/*.template | ||
|
||
replace="s/%%VERSION%%/$3/g" | ||
sed -i '' -e $replace dist/*.template | ||
|
||
cd ../source | ||
cp $template_dir/serverless-image-handler.template $template_dist_dir/ | ||
|
||
replace="s/%%BUCKET_NAME%%/$1/g" | ||
echo "sed -i -e $replace" | ||
sed -i -e $replace $template_dist_dir/serverless-image-handler.template | ||
|
||
replace="s/%%SOLUTION_NAME%%/$2/g" | ||
echo "sed -i -e $replace" | ||
sed -i -e $replace $template_dist_dir/serverless-image-handler.template | ||
|
||
replace="s/%%VERSION%%/$3/g" | ||
echo "sed -i -e $replace" | ||
sed -i -e $replace $template_dist_dir/serverless-image-handler.template | ||
|
||
cp $template_dist_dir/serverless-image-handler.template $build_dist_dir/ | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Package the image-handler code" | ||
echo "------------------------------------------------------------------------------" | ||
cd image-handler | ||
npm install | ||
npm run build | ||
cp dist/image-handler.zip ../../deployment/dist/image-handler.zip | ||
cd $source_dir/image-handler | ||
npm install | ||
npm run build | ||
cp dist/image-handler.zip $build_dist_dir/image-handler.zip | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Package the demo-ui assets" | ||
echo "------------------------------------------------------------------------------" | ||
cd .. | ||
cp -r ./demo-ui/** ../deployment/dist/demo-ui | ||
mkdir $build_dist_dir/demo-ui/ | ||
cp -r $source_dir/demo-ui/** $build_dist_dir/demo-ui/ | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Package the custom-resource code" | ||
echo "------------------------------------------------------------------------------" | ||
cd custom-resource | ||
npm install | ||
npm run build | ||
cp dist/custom-resource.zip ../../deployment/dist/custom-resource.zip | ||
cd $source_dir/custom-resource | ||
npm install | ||
npm run build | ||
cp dist/custom-resource.zip $build_dist_dir/custom-resource.zip | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Generate the demo-ui manifest document" | ||
echo "------------------------------------------------------------------------------" | ||
cd ../../deployment/manifest-generator | ||
cd $template_dir/manifest-generator | ||
npm install | ||
node app.js --target ../../source/demo-ui --output ../dist/demo-ui-manifest.json | ||
node app.js --target ../../source/demo-ui --output $build_dist_dir/demo-ui-manifest.json |
Oops, something went wrong.