Skip to content

Commit

Permalink
Update to version v5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aassadza committed Aug 31, 2020
1 parent 19cbc3c commit cab57be
Show file tree
Hide file tree
Showing 38 changed files with 2,442 additions and 4,338 deletions.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
<!-- A clear and concise description of what the bug is. -->

**To Reproduce**
<!-- Steps to reproduce the behavior. -->

**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->

**Please complete the following information about the solution:**
- [ ] Version: [e.g. v1.0.0]
- [ ] Region: [e.g. us-east-1]
- [ ] Was the solution modified from the version published on this repository?
- [ ] If the answer to the previous question was yes, are the changes available on GitHub?
- [ ] Have you checked your [service quotas](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html) for the sevices this solution uses?
- [ ] Were there any errors in the CloudWatch Logs?

**Screenshots**
<!-- If applicable, add screenshots to help explain your problem (please DO NOT include sensitive information). -->

**Additional context**
<!-- Add any other context about the problem here. -->
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this solution
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the feature you'd like**
<!-- A clear and concise description of what you want to happen.-->

**Additional context**
<!-- Add any other context or screenshots about the feature request here.-->
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/general_question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: General question
about: Ask a general question
title: ''
labels: question
assignees: ''

---

**What is your question?**
<!-- Describe your question as detail as possible. -->
12 changes: 10 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
*Issue #, if available:*
**Issue #, if available:**
<!-- If there're any related issues, please add the issue number here. -->

*Description of changes:*


**Description of changes:**
<!-- Please describe the changes you made -->


**Checklist**
- [ ] :wave: I have run the unit tests, and all unit tests have passed.
- [ ] :warning: This pull request migh incur a breaking change.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ 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).

## [5.0] - 2020-08-31
### Added
- AWS CDK and AWS Solutions Constructs to create AWS CloudFormation template

### Fixed
- Auto WebP does not work properly: [#195](https://github.com/awslabs/serverless-image-handler/pull/195), [#200](https://github.com/awslabs/serverless-image-handler/issues/200), [#205](https://github.com/awslabs/serverless-image-handler/issues/205)
- A bug where base64 encoding containing slash: [#194](https://github.com/awslabs/serverless-image-handler/pull/194)
- Thumbor issues:
- `0` size support: [#183](https://github.com/awslabs/serverless-image-handler/issues/183)
- `convolution` filter does not work: [#187](https://github.com/awslabs/serverless-image-handler/issues/187)
- `fill` filter does not work: [#190](https://github.com/awslabs/serverless-image-handler/issues/190)
- __Note that__ duplicated features has been merged gracefully.

### Removed
- AWS CloudFormation template: `serverless-image-handler.template`

### Changed
- sharp base version (from 0.23.4 to 0.25.4)
- Remove `Promise` to return since `async` functions return promises: [#189](https://github.com/awslabs/serverless-image-handler/issues/189)
- Unit test statement coverage improvement:
- `image-handler.js`: `79.05%` to `100%`
- `image-request.js`: `93.58%` to `100%`
- `thumbor-mapping.js`: `99.29%` to `100%`
- `overall`: `91.55%` to `100%`

## [4.2] - 2020-02-06
### Added
- Honor outputFormat Parameter from the pull request [#117](https://github.com/awslabs/serverless-image-handler/pull/117)
Expand All @@ -16,7 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- fix: DeprecationWarning: Buffer() is deprecated from the pull request [#174](https://github.com/awslabs/serverless-image-handler/pull/174)
- Add hex color support for Thumbor ```filters:background_color``` and ```filters:fill``` [#154](https://github.com/awslabs/serverless-image-handler/issues/154)
- Add format and watermark support for Thumbor [#109](https://github.com/awslabs/serverless-image-handler/issues/109), [#131](https://github.com/awslabs/serverless-image-handler/issues/131), [#109](https://github.com/awslabs/serverless-image-handler/issues/142)
* __Note that__ duplicated features has been merged gracefully.
- __Note that__ duplicated features has been merged gracefully.

### Changed
- sharp base version (from 0.23.3 to 0.23.4)
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Serverless Image Handler

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

**********************
THIRD PARTY COMPONENTS
Expand Down
72 changes: 56 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,84 @@ Published version, additional details and documentation are available here: http

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

## Building distributable for customization
* Clone the repository, then make the desired code changes
## On This Page
- [Architecture Overview](#architecture-overview)
- [Creating a custom build](#creating-a-custom-build)
- [External Contributors](#external-contributors)
- [License](#license)

## Architecture Overview
![Architecture](architecture.jpeg)

The AWS CloudFormation template deploys an Amazon CloudFront distribution, Amazon API Gateway REST API, and an AWS Lambda function. Amazon CloudFront provides a caching layer to reduce the cost of image processing and the latency of subsequent image delivery. The Amazon API Gateway provides endpoint resources and triggers the AWS Lambda function. The AWS Lambda function retrieves the image from the customer's Amazon Simple Storage Service (Amazon S3) bucket and uses Sharp to return a modified version of the image to the API Gateway. Additionally, the solution generates a CloudFront domain name that provides cached access to the image handler API.

_**Note**:_ From v5.0, all AWS CloudFormation template resources are created be [AWS CDK](https://aws.amazon.com/cdk/) and [AWS Solutions Constructs](https://aws.amazon.com/solutions/constructs/). Since the AWS CloudFormation template resources have the same logical ID comparing to v4.x, it makes the solution upgradable mostly from v4.x to v5.

## Creating a custom build
The solution can be deployed through the CloudFormation template available on the solution home page.
To make changes to the solution, download or clone this repo, update the source code and then run the deployment/build-s3-dist.sh script to deploy the updated Lambda code to an Amazon S3 bucket in your account.

### Prerequisites:
* [AWS Command Line Interface](https://aws.amazon.com/cli/)
* Node.js 12.x or later

### 1. Clone the repository
```bash
git clone https://github.com/awslabs/serverless-image-handler.git
```

* Run unit tests to make sure added customization passes the tests:
```
### 2. Run unit tests for customization
Run unit tests to make sure added customization passes the tests:
```bash
cd ./deployment
chmod +x ./run-unit-tests.sh
./run-unit-tests.sh
```

* Create an Amazon S3 Bucket
### 3. Declare environment variables
```bash
export REGION=aws-region-code # the AWS region to launch the solution (e.g. us-east-1)
export DIST_OUTPUT_BUCKET=my-bucket-name # bucket where customized code will reside
export SOLUTION_NAME=my-solution-name # the solution name
export VERSION=my-version # version number for the customized code
```
aws s3 mb s3://my-bucket-us-east-1 --region us-east-1

### 4. Create an Amazon S3 Bucket
The CloudFormation template is configured to pull the Lambda deployment packages from Amazon S3 bucket in the region the template is being launched in. Create a bucket in the desired region with the region name appended to the name of the bucket.
```bash
aws s3 mb s3://$DIST_OUTPUT_BUCKET-$REGION --region $REGION
```

* Navigate to the deployment folder and build the distributable
### 5. Create the deployment packages
Build the distributable:
```bash
chmod +x ./build-s3-dist.sh
./build-s3-dist.sh my-bucket serverless-image-handler my-version
./build-s3-dist.sh $DIST_OUTPUT_BUCKET $SOLUTION_NAME $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 (you must have the AWS CLI installed)
Deploy the distributable to the Amazon S3 bucket in your account:
```bash
aws s3 cp ./regional-s3-assets/ s3://my-bucket-us-east-1/serverless-image-handler/my-version/ --recursive --acl bucket-owner-full-control
aws s3 sync ./regional-s3-assets/ s3://$DIST_OUTPUT_BUCKET-$REGION/$SOLUTION_NAME/$VERSION/ --recursive --acl bucket-owner-full-control
aws s3 sync ./global-s3-assets/ s3://$DIST_OUTPUT_BUCKET-$REGION/$SOLUTION_NAME/$VERSION/ --recursive --acl bucket-owner-full-control
```

* Get the link of the serverless-image-handler.template uploaded to your Amazon S3 bucket
### 6. Launch the CloudFormation template.
* 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 S3 link of the `serverless-image-handler.template`.

* 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
## External Contributors
- [@leviwilson](https://github.com/leviwilson) for [#117](https://github.com/awslabs/serverless-image-handler/pull/117)
- [@rpong](https://github.com/rpong) for [#130](https://github.com/awslabs/serverless-image-handler/pull/130)
- [@harriswong](https://github.com/harriswong) for [#138](https://github.com/awslabs/serverless-image-handler/pull/138)
- [@ganey](https://github.com/ganey) for [#139](https://github.com/awslabs/serverless-image-handler/pull/139)
- [@browniebroke](https://github.com/browniebroke) for [#151](https://github.com/awslabs/serverless-image-handler/pull/151), [#152](https://github.com/awslabs/serverless-image-handler/pull/152)
- [@john-shaffer](https://github.com/john-shaffer) for [#158](https://github.com/awslabs/serverless-image-handler/pull/158)
- [@toredash](https://github.com/toredash) for [#174](https://github.com/awslabs/serverless-image-handler/pull/174), [#195](https://github.com/awslabs/serverless-image-handler/pull/195)
- [@lith-imad](https://github.com/lith-imad) for [#194](https://github.com/awslabs/serverless-image-handler/pull/194)

***

Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
## License
Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Binary file added architecture.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 8 additions & 15 deletions deployment/build-s3-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,16 @@ rm -rf $build_dist_dir
mkdir -p $build_dist_dir

echo "------------------------------------------------------------------------------"
echo "CloudFormation Template"
echo "CloudFormation template with CDK and Constructs"
echo "------------------------------------------------------------------------------"
cp $template_dir/serverless-image-handler.template $template_dist_dir/
export BUCKET_NAME=$1
export SOLUTION_NAME=$2
export VERSION=$3

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/
cd $source_dir/constructs
npm install
npm run build && cdk synth --asset-metadata false --path-metadata false --version-reporting false --json true > serverless-image-handler.json
mv serverless-image-handler.json $template_dist_dir/serverless-image-handler.template

echo "------------------------------------------------------------------------------"
echo "Package the image-handler code"
Expand Down
63 changes: 0 additions & 63 deletions deployment/manifest-generator/app.js

This file was deleted.

9 changes: 8 additions & 1 deletion deployment/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@

set -e

cd ../source/image-handler
current_dir=$PWD
source_dir=$current_dir/../source

cd $source_dir/constructs
npm install
npm test

cd $source_dir/image-handler
npm test
Loading

0 comments on commit cab57be

Please sign in to comment.