Skip to content

Commit 5c0c83b

Browse files
authored
Merge branch 'master' into master
2 parents aae497d + a7ee268 commit 5c0c83b

25 files changed

+1414
-1037
lines changed

.gitignore

100644100755
Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1+
# compiled output
2+
**/dist
3+
**/global-s3-assets
4+
**/regional-s3-assets
5+
**/open-source
6+
**/.zip
7+
**/tmp
8+
**/out-tsc
9+
10+
# dependencies
11+
**/node_modules
12+
13+
# test assets
14+
**/coverage
15+
**/.nyc_output
16+
17+
# misc
18+
**/npm-debug.log
19+
**/testem.log
20+
**/package-lock.json
21+
**/.vscode/settings.json
22+
demo-ui-config.js
23+
124
# System Files
2-
**/.DS_Store
25+
**/.DS_Store
26+
**/.vscode

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [4.1] - 2019-12-31
8+
### Added
9+
- CHANGELOG file
10+
- Access logging to API Gateway
11+
12+
### Changed
13+
- Lambda functions runtime to nodejs12.x
14+
- sharp version (from 0.21.3 to 0.23.3)
15+
- Image handler function to use Composite API (https://sharp.pixelplumbing.com/en/stable/api-composite/)
16+
- License to Apache-2.0
17+
18+
# Removed
19+
- Reference to deprecated sharp function (overlayWith)

CONTRIBUTING.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# Contributing Guidelines
2-
32
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
43
documentation, we greatly value feedback and contributions from our community.
54

65
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
76
information to effectively respond to your bug report or contribution.
87

9-
108
## Reporting Bugs/Feature Requests
11-
129
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
1310

1411
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
1916
* Any modifications you've made relevant to the bug
2017
* Anything unusual about your environment or deployment
2118

22-
2319
## Contributing via Pull Requests
2420
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
2521

@@ -39,23 +35,17 @@ To send us a pull request, please:
3935
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
4036
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4137

42-
4338
## Finding contributions to work on
4439
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.
4540

46-
4741
## Code of Conduct
4842
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
4943
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
5044
[email protected] with any additional questions or comments.
5145

52-
5346
## Security issue notifications
5447
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.
5548

56-
5749
## Licensing
58-
59-
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.
60-
50+
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.
6151
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.

LICENSE.txt

Lines changed: 202 additions & 32 deletions
Large diffs are not rendered by default.

NOTICE.txt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
Serverless Image Handler
2+
23
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
Licensed under the Amazon Software License (the "License"). You may not use this file except
4-
in compliance with the License. A copy of the License is located at http://aws.amazon.com/asl/
5-
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
6-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the
7-
specific language governing permissions and limitations under the License.
84

95
**********************
106
THIRD PARTY COMPONENTS
117
**********************
128
This software includes third party software subject to the following copyrights:
139

14-
AWS SDK under the Apache License Version 2.0
15-
uuid under the Massachusetts Institute of Technology (MIT) license
16-
sharp under the Apache License Version 2.0
17-
sinon under the BSD 3-Clause license
10+
aws-sdk under the Apache License Version 2.0
11+
aws-sdk-mock under the Apache License Version 2.0
12+
Bootstrap under the Massachusetts Institute of Technology (MIT) license
1813
chai under the Massachusetts Institute of Technology (MIT) license
19-
sinon-chai under the BSD 2-Clause license
14+
minimist under the Massachusetts Institute of Technology (MIT) license
2015
mocha under the Massachusetts Institute of Technology (MIT) license
16+
moment under the Massachusetts Institute of Technology (MIT) license
17+
npm-run-all under the Massachusetts Institute of Technology (MIT) license
2118
nyc under the ISC license
22-
23-
The licenses for these third party components are included in LICENSE.txt
19+
sharp under the Apache License Version 2.0
20+
sinon under the BSD-3-Clause license
21+
sinon-chai under the BSD-2-Clause license
22+
uuid under the Massachusetts Institute of Technology (MIT) license

README.md

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,59 @@
1+
**_Important Notice:_**
2+
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.
3+
14
# AWS Serverless Image Handler Lambda wrapper for SharpJS
25
A solution to dynamically handle images on the fly, utilizing Sharp (https://sharp.pixelplumbing.com/en/stable/).
36
Published version, additional details and documentation are available here: https://aws.amazon.com/solutions/serverless-image-handler/
47

58
_Note:_ it is recommend to build the application binary on Amazon Linux.
69

7-
## Running unit tests for customization
10+
## Building distributable for customization
811
* Clone the repository, then make the desired code changes
9-
* Next, run unit tests to make sure added customization passes the tests
10-
```
11-
cd ./deployment
12-
chmod +x ./run-unit-tests.sh \n
13-
./run-unit-tests.sh \n
12+
```bash
13+
git clone https://github.com/awslabs/serverless-image-handler.git
1414
```
1515

16-
## Building distributable for customization
17-
* Configure the bucket name of your target Amazon S3 distribution bucket
16+
* Run unit tests to make sure added customization passes the tests:
1817
```
19-
export TEMPLATE_OUTPUT_BUCKET=my-bucket-name # bucket where cfn template will reside
20-
export DIST_OUTPUT_BUCKET=my-bucket-name # bucket where customized code will reside
21-
export VERSION=my-version # version number for the customized code
18+
cd ./deployment
19+
chmod +x ./run-unit-tests.sh
20+
./run-unit-tests.sh
2221
```
23-
_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.
2422

23+
* Create an Amazon S3 Bucket
2524
```
26-
* Clone the github repo
27-
```bash
28-
git clone https://github.com/awslabs/serverless-image-handler.git
25+
aws s3 mb s3://my-bucket-us-east-1 --region us-east-1
2926
```
3027

31-
* Navigate to the deployment folder
28+
* Navigate to the deployment folder and build the distributable
3229
```bash
33-
cd serverless-image-handler/deployment
30+
chmod +x ./build-s3-dist.sh
31+
./build-s3-dist.sh my-bucket serverless-image-handler my-version
3432
```
3533

36-
* Now build the distributable
37-
```bash
38-
sudo ./build-s3-dist.sh $DIST_OUTPUT_BUCKET $TEMPLATE_OUTPUT_BUCKET $VERSION
39-
```
34+
> Note: The build-s3-dist script expects the bucket name as one of its parameters, and this value should not include the region suffix.
4035
41-
* Deploy the distributable to an Amazon S3 bucket in your account. Note: you must have the AWS Command Line Interface installed.
36+
* Deploy the distributable to an Amazon S3 bucket in your account (you must have the AWS CLI installed)
4237
```bash
43-
aws s3 cp ./dist/ s3://$DIST_OUTPUT_BUCKET-[region_name]/serverless-image-handler/$VERSION/ --recursive --exclude "*" --include "*.zip"
44-
aws s3 cp ./dist/serverless-image-handler.template s3://$TEMPLATE_OUTPUT_BUCKET/serverless-image-handler/$VERSION/
38+
aws s3 cp ./regional-s3-assets/ s3://my-bucket-us-east-1/serverless-image-handler/my-version/ --recursive --acl bucket-owner-full-control
4539
```
46-
_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
4740

48-
* Get the link of the serverless-image-handler.template uploaded to your Amazon S3 bucket.
41+
* Get the link of the serverless-image-handler.template uploaded to your Amazon S3 bucket
42+
4943
* 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
50-
```bash
51-
https://s3.amazonaws.com/my-bucket-name/serverless-image-handler/my-version/serverless-image-handler.template
52-
```
44+
45+
***
5346

5447
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5548

56-
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
49+
Licensed under the Apache License, Version 2.0 (the "License");
50+
you may not use this file except in compliance with the License.
51+
You may obtain a copy of the License at
5752

58-
http://aws.amazon.com/asl/
53+
http://www.apache.org/licenses/LICENSE-2.0
5954

60-
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.
55+
Unless required by applicable law or agreed to in writing, software
56+
distributed under the License is distributed on an "AS IS" BASIS,
57+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58+
See the License for the specific language governing permissions and
59+
limitations under the License.

deployment/build-s3-dist.sh

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,88 @@
1+
#!/bin/bash
2+
#
3+
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
4+
#
5+
# This script should be run from the repo's deployment directory
6+
# cd deployment
7+
# ./build-s3-dist.sh source-bucket-base-name trademarked-solution-name version-code
8+
#
9+
# Paramenters:
10+
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
11+
# code from. The template will append '-[region_name]' to this bucket name.
12+
# For example: ./build-s3-dist.sh solutions my-solution v1.0.0
13+
# The template will then expect the source code to be located in the solutions-[region_name] bucket
14+
#
15+
# - trademarked-solution-name: name of the solution for consistency
16+
#
17+
# - version-code: version of the package
18+
19+
# Check to see if input has been provided:
20+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
21+
echo "Please provide the base source bucket name, trademark approved solution name and version where the lambda code will eventually reside."
22+
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.0"
23+
exit 1
24+
fi
25+
26+
set -e
27+
28+
# Get reference for all important folders
29+
template_dir="$PWD"
30+
template_dist_dir="$template_dir/global-s3-assets"
31+
build_dist_dir="$template_dir/regional-s3-assets"
32+
source_dir="$template_dir/../source"
33+
134
echo "------------------------------------------------------------------------------"
2-
echo "Setup the dist folder"
35+
echo "Rebuild distribution"
336
echo "------------------------------------------------------------------------------"
4-
rm -r dist
5-
mkdir dist
6-
cd dist
7-
mkdir demo-ui
8-
cd ..
37+
rm -rf $template_dist_dir
38+
mkdir -p $template_dist_dir
39+
rm -rf $build_dist_dir
40+
mkdir -p $build_dist_dir
941

1042
echo "------------------------------------------------------------------------------"
11-
echo "Copy in the template"
43+
echo "CloudFormation Template"
1244
echo "------------------------------------------------------------------------------"
13-
cp *.template dist/
14-
15-
replace="s/%%BUCKET_NAME%%/$1/g"
16-
sed -i '' -e $replace dist/*.template
17-
18-
replace="s/%%TEMPLATE_BUCKET%%/$2/g"
19-
sed -i '' -e $replace dist/*.template
20-
21-
replace="s/%%VERSION%%/$3/g"
22-
sed -i '' -e $replace dist/*.template
23-
24-
cd ../source
45+
cp $template_dir/serverless-image-handler.template $template_dist_dir/
46+
47+
replace="s/%%BUCKET_NAME%%/$1/g"
48+
echo "sed -i -e $replace"
49+
sed -i -e $replace $template_dist_dir/serverless-image-handler.template
50+
51+
replace="s/%%SOLUTION_NAME%%/$2/g"
52+
echo "sed -i -e $replace"
53+
sed -i -e $replace $template_dist_dir/serverless-image-handler.template
54+
55+
replace="s/%%VERSION%%/$3/g"
56+
echo "sed -i -e $replace"
57+
sed -i -e $replace $template_dist_dir/serverless-image-handler.template
58+
59+
cp $template_dist_dir/serverless-image-handler.template $build_dist_dir/
2560

2661
echo "------------------------------------------------------------------------------"
2762
echo "Package the image-handler code"
2863
echo "------------------------------------------------------------------------------"
29-
cd image-handler
30-
npm install
31-
npm run build
32-
cp dist/image-handler.zip ../../deployment/dist/image-handler.zip
64+
cd $source_dir/image-handler
65+
npm install
66+
npm run build
67+
cp dist/image-handler.zip $build_dist_dir/image-handler.zip
3368

3469
echo "------------------------------------------------------------------------------"
3570
echo "Package the demo-ui assets"
3671
echo "------------------------------------------------------------------------------"
37-
cd ..
38-
cp -r ./demo-ui/** ../deployment/dist/demo-ui
72+
mkdir $build_dist_dir/demo-ui/
73+
cp -r $source_dir/demo-ui/** $build_dist_dir/demo-ui/
3974

4075
echo "------------------------------------------------------------------------------"
4176
echo "Package the custom-resource code"
4277
echo "------------------------------------------------------------------------------"
43-
cd custom-resource
44-
npm install
45-
npm run build
46-
cp dist/custom-resource.zip ../../deployment/dist/custom-resource.zip
78+
cd $source_dir/custom-resource
79+
npm install
80+
npm run build
81+
cp dist/custom-resource.zip $build_dist_dir/custom-resource.zip
4782

4883
echo "------------------------------------------------------------------------------"
4984
echo "Generate the demo-ui manifest document"
5085
echo "------------------------------------------------------------------------------"
51-
cd ../../deployment/manifest-generator
86+
cd $template_dir/manifest-generator
5287
npm install
53-
node app.js --target ../../source/demo-ui --output ../dist/demo-ui-manifest.json
88+
node app.js --target ../../source/demo-ui --output $build_dist_dir/demo-ui-manifest.json

0 commit comments

Comments
 (0)