Skip to content

Commit

Permalink
Implement IIIFv3 and Lambda response streaming
Browse files Browse the repository at this point in the history
- Convert Lambda to streaming function url
- Use IIIF v3 branch of node-iiif
- Add IIIF v3 tests and other supports
- Add service discovery endpoint at `/`
- Create Terraform module
- Create CloudFormation and Terraform examples
- Enhance docs
- Build CloudFormation & Terraform documentation dynamically
- Refactor build/deploy/delete commands to use new YAML config
- Update to NodeJS v18.x
- Update to aws-sdk v3

Co-Authored-By: Rob Kaufman <[email protected]>
  • Loading branch information
mbklein and orangewolf committed Aug 22, 2023
1 parent 5b11836 commit 118bf50
Show file tree
Hide file tree
Showing 63 changed files with 16,326 additions and 9,355 deletions.
24 changes: 0 additions & 24 deletions .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"space-in-parens": ["error", "never"],

// This should replicate Code Climate's computational complexity code smells warning. It is actually more strict.
"complexity": ["warn", 5]
"complexity": ["warn", 6]
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# AWS SAM
.aws
.aws-sam
deploy.yml
deploy.yaml
node_modules
samconfig.toml
env.json
package.yml
samconfig.toml
package.yaml
samconfig.*

# NodeJS Build
coverage
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
[![Maintainability](https://api.codeclimate.com/v1/badges/4ac80b539190cb5b082f/maintainability)](https://codeclimate.com/github/samvera/serverless-iiif/maintainability)
[![Test Coverage](https://coveralls.io/repos/github/samvera/serverless-iiif/badge.svg)](https://coveralls.io/github/samvera/serverless-iiif)

## Upgrade Note

Previous versions of this application featured an optional [CloudFront](https://aws.amazon.com/cloudfront/) distribution that provided caching, custom domain/hostname mapping, and request/response pre/post-processing. However, the primary motivation for including this feature in the past was that it provided a complicated but effective way to skirt the hard 6 megabyte limit for Lambda function response payloads. Since then, AWS has introduced [AWS Lambda response streaming](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/), which uses chunked responses to bypass the 6 megabyte limit. As this is a much more elegant solution to the problem, there's nothing about the CloudFront template that's specific to this project any more. Ongoing development and maintenance will therefore focus on the IIIF Lambda itself rather than the large, complicated template required for a flexible, customizable CloudFront deployment.

While the CloudFront-enabled version of the application is no longer available in the Serverless Application Repository, the newly created [`examples`](./examples/README.md) directory includes sample [CloudFormation](https://aws.amazon.com/cloudformation/) templates and [Terraform](https://terraform.io/) manifests showing how to deploy the IIIF service as part of a larger application/infrastructure stack.

## Description

A [IIIF 2.1 Image API](https://iiif.io/api/image/2.1/) compliant server written as an [AWS Serverless Application](https://aws.amazon.com/serverless/sam/).
A IIIF [2.1](https://iiif.io/api/image/2.1/) and [3.0](https://iiif.io/api/image/3.0/) Image API compliant server written as an [AWS Serverless Application](https://aws.amazon.com/serverless/sam/).

## Components

Expand Down Expand Up @@ -56,7 +62,7 @@ A [IIIF 2.1 Image API](https://iiif.io/api/image/2.1/) compliant server written
1. Make sure you have the [SAM CLI](https://aws.amazon.com/serverless/sam/) and [AWS CLI](https://aws.amazon.com/cli/) installed.
2. Make sure the AWS CLI is [properly configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) with credentials that have sufficient access to manage IAM, S3, Lambda, and (optionally) CloudFront resources.
3. Clone this repository.
4. Copy .env.example to .env. Update the various values within.
4. Copy deploy.yml.example to deploy.yml
5. Build the application:
```shell
$ npm run build
Expand All @@ -65,10 +71,10 @@ A [IIIF 2.1 Image API](https://iiif.io/api/image/2.1/) compliant server written
```shell
$ npm run deploy
```

You'll be prompted for various configuration parameters, confirmations, and acknowledgments of specific issues (particularly the creation of IAM resources and the deployment of an open/unauthenticated Lambda Function URL).
7. Follow the prompts to complete the deployment process and get the resulting endpoint.

If you'd repfer you can run `npm run deploy-guided`. You'll be prompted for various configuration parameters, confirmations, and acknowledgments of specific issues (particularly the creation of IAM resources and the deployment of an open/unauthenticated Lambda Function URL).

### Deleting the application

The easiest way to delete the application is either from the [Lambda Applications Console](https://console.aws.amazon.com/lambda/home#/applications) or by deleting its [CloudFormation Stack](https://console.aws.amazon.com/cloudformation/home#/stacks?filteringStatus=active&filteringText=&viewNested=true&hideStacks=false). If you deployed from the command line, you can also use the `npm run delete` command.
Expand Down Expand Up @@ -105,7 +111,7 @@ npm test --coverage
## Custom Sharp Layer
This lambda uses the Sharp layer from https://github.com/samvera/lambda-layer-sharp-jp2/releases in order to get a version of Sharp with jp2 support. You can build your own local version using that code and then copy the file to serverless-iiif/sharp-lambda-layer.x86_64.zip. Then set LOCAL_SHARP=true and build/deploy to use your own version.
This lambda uses the Sharp layer from https://github.com/samvera/lambda-layer-sharp-jp2/releases in order to get a version of Sharp with jp2 support. You can build your own local version using that code and then deploy your own layer and set that layer in your SAM template.
## Advanced Usage
Expand Down
21 changes: 0 additions & 21 deletions bin/build

This file was deleted.

18 changes: 0 additions & 18 deletions bin/delete

This file was deleted.

45 changes: 0 additions & 45 deletions bin/deploy

This file was deleted.

18 changes: 0 additions & 18 deletions bin/setup.js

This file was deleted.

15 changes: 8 additions & 7 deletions bin/update_version
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ for f in $root/package.json $root/src/package.json $root/dependencies/package.js
jq --arg v "$version" '.version = $v' <<< $content > $f
done

for f in $root/sam/standalone/template.yml $root/sam/cloudfront/template.yml; do
if [[ "$OSTYPE" = "darwin*" ]]; then
sed -i '' -E "s/SemanticVersion: .+/SemanticVersion: $version/" $f
else
sed -i'' -E "s/SemanticVersion: .+/SemanticVersion: $version/" $f
fi
done
if [[ "$OSTYPE" = "darwin*" ]]; then
sedreplace="sed -i ''"
else
sedreplace="sed -i''"
fi

$sedreplace -E "s/SemanticVersion: .+/SemanticVersion: $version/" $root/sam/template.yml
$sedreplace -E "s/ serverless_iiif_app_version =.+/ serverless_iiif_app_version = \"$version\"" $root/extras/terraform/main.tf
Loading

0 comments on commit 118bf50

Please sign in to comment.