Skip to content

Commit f533e90

Browse files
author
Viet Pham
committed
Added Atlas stuff
1 parent a7ee268 commit f533e90

File tree

5 files changed

+491
-44
lines changed

5 files changed

+491
-44
lines changed

README.md

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,14 @@
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.
31

4-
# AWS Serverless Image Handler Lambda wrapper for SharpJS
5-
A solution to dynamically handle images on the fly, utilizing Sharp (https://sharp.pixelplumbing.com/en/stable/).
6-
Published version, additional details and documentation are available here: https://aws.amazon.com/solutions/serverless-image-handler/
72

8-
_Note:_ it is recommend to build the application binary on Amazon Linux.
3+
## Usage
94

10-
## Building distributable for customization
11-
* Clone the repository, then make the desired code changes
125
```bash
13-
git clone https://github.com/awslabs/serverless-image-handler.git
6+
./atlas-deploy.sh deploy_stack|build|update
147
```
158

16-
* Run unit tests to make sure added customization passes the tests:
17-
```
18-
cd ./deployment
19-
chmod +x ./run-unit-tests.sh
20-
./run-unit-tests.sh
21-
```
22-
23-
* Create an Amazon S3 Bucket
24-
```
25-
aws s3 mb s3://my-bucket-us-east-1 --region us-east-1
26-
```
27-
28-
* Navigate to the deployment folder and build the distributable
29-
```bash
30-
chmod +x ./build-s3-dist.sh
31-
./build-s3-dist.sh my-bucket serverless-image-handler my-version
32-
```
33-
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.
35-
36-
* Deploy the distributable to an Amazon S3 bucket in your account (you must have the AWS CLI installed)
37-
```bash
38-
aws s3 cp ./regional-s3-assets/ s3://my-bucket-us-east-1/serverless-image-handler/my-version/ --recursive --acl bucket-owner-full-control
39-
```
40-
41-
* Get the link of the serverless-image-handler.template uploaded to your Amazon S3 bucket
42-
43-
* 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
9+
* `deploy_stack`: Deploy Cloudformation stack
10+
* `build`: Build & package image handler function
11+
* `update`: Trigger lambda function update from built code from s3
4412

4513
***
4614

deployment/atlas-deploy.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
export AWS_PROFILE=${AWS_PROFILE:-default}
4+
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-east-1}
5+
6+
set -e
7+
8+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
9+
SOURCE_DIR="$DIR/../source"
10+
11+
deploy_stack() {
12+
set -x
13+
aws cloudformation deploy \
14+
--no-fail-on-empty-changeset \
15+
--stack-name "atlas-image-handler" \
16+
--template-file "$DIR/atlas-image-handler.template" \
17+
--capabilities CAPABILITY_NAMED_IAM
18+
}
19+
20+
build() {
21+
set -x
22+
cd ${SOURCE_DIR}/image-handler
23+
npm install
24+
npm run build
25+
26+
aws s3 cp dist/image-handler.zip s3://atlas-lambdas-us-east-1/atlas-image-handler/production/ --acl bucket-owner-full-control
27+
}
28+
29+
update_code() {
30+
set -x
31+
aws lambda update-function-code \
32+
--function-name atlas-image-handler \
33+
--s3-bucket atlas-lambdas-${AWS_DEFAULT_REGION} \
34+
--s3-key atlas-image-handler/production/image-handler.zip
35+
}
36+
37+
action=${1:-"deploy_stack"}
38+
if [[ "$action" == "deploy_stack" ]]; then
39+
deploy_stack
40+
exit 0
41+
fi
42+
43+
if [[ "$action" == "build" ]]; then
44+
build
45+
exit 0
46+
fi
47+
48+
if [[ "$action" == "update" ]]; then
49+
update_code
50+
exit 0
51+
fi
52+
53+
echo "Usage: ./atlas-deploy.sh deploy_stack|build|update"

0 commit comments

Comments
 (0)