Skip to content

Latest commit

 

History

History
112 lines (69 loc) · 3.43 KB

README.md

File metadata and controls

112 lines (69 loc) · 3.43 KB

Ghostscript for AWS Lambda

Scripts to compile Ghostscript (gs) for AWS Lambda instances powered by Amazon Linux 2.x, such as the nodejs10.x runtime, and the updated 2018.03 Amazon Linux 1 runtimes.

Usage

Absolutely the easiest way of using this is to pull it directly from the AWS Serverless Application repository into a CloudFormation/SAM application, or deploy directly from the Serverless Application Repository into your account, and then link as a layer.

For more information, check out the ghostscript-lambda-layer application in the Serverless App Repository.

For manual deployments and custom builds, read below...

Prerequisites

  • Docker desktop
  • Unix Make environment
  • AWS command line utilities (just for deployment)

Compiling the code

  • start Docker services
  • make all

There are two make scripts in this project.

  • Makefile is intended to run on the build system, and just starts a Docker container matching the AWS Linux 2 environment for Lambda runtimes to compile Ghostscript using the second script.
  • Makefile_gs is the script that will run inside the container, and actually compile binaries.

The output will be in the result dir.

Configuring the build

By default, this compiles a version expecting to run as a Lambda layer from /opt. You can change the expected location by providing a TARGET variable when invoking make.

The default Docker image used is lambci/lambda-base-2:build. To use a different base, provide a DOCKER_IMAGE variable when invoking make.

Modify the versions of libraries or Ghostscript directly in Makefile_gs.

Deploying to AWS as a layer

Run the following command to deploy the compiled result as a layer in your AWS account.

Staging

aws-vault exec main-staging make deploy DEPLOYMENT_BUCKET=light.staging.main.lambda-layers

Production

aws-vault exec main-production make deploy DEPLOYMENT_BUCKET=light.production.main.lambda-layers

NOTE: Don't forget to update the version table below with the new version number.

Configuring the deployment

By default, this uses ghostscript-layer as the stack name. Provide a STACK_NAME variable when calling make deploy to use an alternative name.

Throbleshooting

If the deployment fails and you get an error like this:

An error occurred (ValidationError) when calling the CreateChangeSet operation: Stack:arn:aws:cloudformation:eu-west-1:934322491391:stack/ghostscript-layer/57003290-0c5c-11ef-bb30-0ae4f6954fa5 is in ROLLBACK_COMPLETE state and can not be updated.

You need to first delete the stack before you can deploy again. To do that, run the following command:

aws-vault exec main-staging aws cloudformation delete-stack --stack-name ghostscript-layer

Versions

Layer Version Ghostscript Version
1 9.27
2 10.02.1

Additional Info

For more information, check out:

Author

Tomislav Capan

License