├── .gitattributes ├── renovate.json ├── .gitignore ├── java.zip ├── .editorconfig ├── publish.sh ├── license └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | *.zip filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["github>shelfio/renovate-config-public"], 3 | "labels": ["backend"] 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | coverage/ 3 | node_modules/ 4 | temp 5 | yarn.lock 6 | *.log 7 | .DS_Store 8 | lib/ 9 | layer/ 10 | -------------------------------------------------------------------------------- /java.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4f100a5ff58ff5b7f71da69760e573a3c9e8de3052d795b7ff4446037a85c3ab 3 | size 53011954 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | aws configure set default.region "$TARGET_REGION" --profile default 4 | 5 | LAYER_NAME='java' 6 | LAYER_DESCRIPTION="Java 8" 7 | S3_BUCKET_NAME=shelf-lambda-layers-"$TARGET_REGION" 8 | FILENAME="java.zip" 9 | 10 | aws s3 cp ./"$FILENAME" s3://"$S3_BUCKET_NAME"/"$FILENAME" 11 | 12 | aws lambda add-layer-version-permission \ 13 | --region "$TARGET_REGION" \ 14 | --layer-name "$LAYER_NAME" \ 15 | --statement-id sid1 \ 16 | --action lambda:GetLayerVersion \ 17 | --principal '*' \ 18 | --version-number "$( 19 | aws lambda publish-layer-version \ 20 | --region "$TARGET_REGION" \ 21 | --layer-name "$LAYER_NAME" \ 22 | --description "$LAYER_DESCRIPTION" \ 23 | --query Version \ 24 | --output text \ 25 | --content S3Bucket="$S3_BUCKET_NAME",S3Key="$FILENAME" 26 | )" 27 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Gemshelf Inc. (shelf.io) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## AWS Lambda layer with Java 8 2 | 3 | The purpose of this layer is to have externalized Java 8, so we can attach it to the lambda whenever it's needed by software we use. 4 | 5 | E.g. after AWS Lambda started to use Amazon Linux 2 OS, Node.js runtime 12.x, 10.x doesn't have Java installed. Previously we had it installed with Node.js 8.10 (Amazon Linux OS), so we were able to use it for other software needs (e.g. Apache Tika). 6 | 7 | ## Getting Started 8 | 9 | Click on Layers and choose "Add a layer", and "Provide a layer version 10 | ARN" and enter the following ARN. 11 | 12 | ``` 13 | arn:aws:lambda:us-east-1:764866452798:layer:java:3 14 | ``` 15 | 16 | ## Where it can be used? 17 | 18 | This layer was initially designed for [Apache Tika Lambda layer](https://github.com/shelfio/apache-tika-lambda-layer) to run on Node.js 12.x runtime, but you can use it for any other purpose you want. 19 | 20 | ## What is the executable path to Java inside of Lambda when I attached the layer? 21 | 22 | You can find it at `/opt/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.lambda2.0.1.x86_64/jre/bin/java` (`/opt` is a location where lambda unpacks layers). 23 | 24 | ## Available regions 25 | 26 | * ap-northeast-1: `arn:aws:lambda:ap-northeast-1:764866452798:layer:java:1` 27 | * ap-northeast-2: `arn:aws:lambda:ap-northeast-2:764866452798:layer:java:1` 28 | * ap-south-1: `arn:aws:lambda:ap-south-1:764866452798:layer:java:1` 29 | * ap-southeast-1: `arn:aws:lambda:ap-southeast-1:764866452798:layer:java:1` 30 | * ap-southeast-2: `arn:aws:lambda:ap-southeast-2:764866452798:layer:java:1` 31 | * ca-central-1: `arn:aws:lambda:ca-central-1:764866452798:layer:java:1` 32 | * eu-north-1: `arn:aws:lambda:eu-north-1:764866452798:layer:java:1` 33 | * eu-central-1: `arn:aws:lambda:eu-central-1:764866452798:layer:java:1` 34 | * eu-west-1: `arn:aws:lambda:eu-west-1:764866452798:layer:java:1` 35 | * eu-west-2: `arn:aws:lambda:eu-west-2:764866452798:layer:java:1` 36 | * eu-west-3: `arn:aws:lambda:eu-west-3:764866452798:layer:java:1` 37 | * sa-east-1: `arn:aws:lambda:sa-east-1:764866452798:layer:java:1` 38 | * us-east-1: `arn:aws:lambda:us-east-1:764866452798:layer:java:3` 39 | * us-east-2: `arn:aws:lambda:us-east-2:764866452798:layer:java:1` 40 | * us-west-1: `arn:aws:lambda:us-west-1:764866452798:layer:java:1` 41 | * us-west-2: `arn:aws:lambda:us-west-2:764866452798:layer:java:1` 42 | 43 | ### How to create a fresh zip archive with Java 8 44 | 45 | ```bash 46 | mkdir java 47 | 48 | docker run --rm -v "$PWD"/java:/lambda/opt lambci/yumda:2 yum install -y java-1.8.0-openjdk-headless.x86_64 49 | 50 | cd java 51 | zip -yr ../java . 52 | cd .. 53 | 54 | rm -R java 55 | ``` 56 | 57 | ## License 58 | 59 | MIT © [Shelf](https://shelf.io) 60 | --------------------------------------------------------------------------------