Skip to content

Commit f47c7c7

Browse files
committed
Version 3.1.0
1 parent 50856dc commit f47c7c7

File tree

20 files changed

+783
-740
lines changed

20 files changed

+783
-740
lines changed

LICENSE.txt

100755100644
File mode changed.

NOTICE.txt

100755100644
Lines changed: 569 additions & 1 deletion
Large diffs are not rendered by default.

README.md

100755100644
Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,73 @@
22
A solution to dynamically handle images on the fly, utilizing Thumbor (thumbor.org).
33
Published version, additional details and documentation are available here: https://aws.amazon.com/answers/web-applications/serverless-image-handler/
44

5-
## OS/Python Environment Setup
5+
_Note:_ it is recommend to build the application binary on Amazon Linux.
6+
7+
## Running unit tests for customization
8+
* 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
14+
```
15+
16+
## Building distributable for customization
17+
* Configure the bucket name of your target Amazon S3 distribution bucket
18+
```
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
22+
```
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.
24+
25+
* OS/Python Environment Setup
626
```bash
27+
yum install yum-utils epel-release -y
728
sudo yum-config-manager --enable epel
829
sudo yum update -y
9-
sudo yum install git libpng-devel libcurl-devel gcc python-devel libjpeg-devel -y
10-
sudo pip install --upgrade pip
30+
sudo yum install zip wget git libpng-devel libcurl-devel gcc python-devel libjpeg-devel -y
1131
alias sudo='sudo env PATH=$PATH'
12-
sudo pip install --upgrade setuptools
13-
sudo pip install --upgrade virtualenv
32+
sudo pip install setuptools==39.0.1
33+
sudo pip install virtualenv==15.2.0
34+
```
35+
* Clone the github repo
36+
```bash
37+
git clone https://github.com/awslabs/serverless-image-handler.git
1438
```
1539

16-
## Building Lambda Package
40+
* Navigate to the deployment folder
1741
```bash
18-
cd deployment
19-
./build-s3-dist.sh source-bucket-base-name
42+
cd serverless-image-handler/deployment
2043
```
21-
source-bucket-base-name should be the base name for the S3 bucket location where the template will source the Lambda code from.
22-
The template will append '-[region_name]' to this value.
23-
For example: ./build-s3-dist.sh solutions
24-
The template will then expect the source code to be located in the solutions-[region_name] bucket
2544

26-
## CF template and Lambda function
27-
Located in deployment/dist
45+
* Now build the distributable
46+
```bash
47+
sudo ./build-s3-dist.sh $DIST_OUTPUT_BUCKET $VERSION
48+
```
2849

50+
* Deploy the distributable to an Amazon S3 bucket in your account. Note: you must have the AWS Command Line Interface installed.
51+
```bash
52+
aws s3 cp ./dist/ s3://$DIST_OUTPUT_BUCKET-[region_name]/serverless-image-handler/$VERSION/ --recursive --exclude "*" --include "*.zip"
53+
aws s3 cp ./dist/serverless-image-handler.template s3://$TEMPLATE_OUTPUT_BUCKET/serverless-image-handler/$VERSION/
54+
```
55+
_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
56+
57+
* Get the link of the serverless-image-handler.template uploaded to your Amazon S3 bucket.
58+
* 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
59+
```bash
60+
https://s3.amazonaws.com/my-bucket-name/serverless-image-handler/my-version/serverless-image-handler.template
61+
```
62+
63+
## SafeURL hash calculation
64+
* For hash calculation with safe URL, use following snippet to find signed_path value
65+
```bash
66+
http_key='mysecuritykey' # security key provided to lambda env variable
67+
http_path='200x200/smart/sub-folder/myimage.jpg' # sample options for myimage
68+
hashed = hmac.new(str(http_key),str(http_path),sha1)
69+
encoded = base64.b64encode(hashed.digest())
70+
signed_path = encoded.replace('/','_').replace('+','-')
71+
```
2972

3073
***
3174

THIRD_PARTY_LICENSES.txt

Lines changed: 0 additions & 565 deletions
This file was deleted.

0 commit comments

Comments
 (0)