Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/axel-op/package-java-aws-lambda
Package a Java AWS Lambda
https://github.com/axel-op/package-java-aws-lambda
aws-lambda aws-lambda-java github-actions maven
Last synced: 10 days ago
JSON representation
Package a Java AWS Lambda
- Host: GitHub
- URL: https://github.com/axel-op/package-java-aws-lambda
- Owner: axel-op
- License: mit
- Created: 2022-11-13T20:13:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-14T12:58:12.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T11:46:28.246Z (24 days ago)
- Topics: aws-lambda, aws-lambda-java, github-actions, maven
- Language: Shell
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Package an AWS Lambda in Java
A GitHub Action to package an AWS Lambda in Java with Maven.
AWS Lambdas in Java [should be packaged as an Uber JAR](https://docs.aws.amazon.com/lambda/latest/dg/java-package.html#java-package-maven).
The [`maven-shade-plugin`](https://maven.apache.org/plugins/maven-shade-plugin) is used to build the Uber JAR. While configuring it in the `pom.xml` is the recommended way to use it, here we execute it from the command line so the `pom.xml` doesn't have to be edited.
## Inputs/Outputs
- The input `working-directory` is optional and indicates where is the root directory of your Lambda function.
- The output `deployment-file` is an absolute path to the JAR that should be deployed (see the example below).## Example workflow
This GitHub Actions workflow shows how to deploy an AWS Lambda [using the `UpdateFunctionCode` API](https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionCode.html) with the `aws` CLI:
```yml
name: Example workflowon:
push:
branches:
- mainjobs:
deploy-aws-lambda:
runs-on: ubuntu-latest
permissions:
# This is required for requesting GitHub's OIDC Token
# See https://github.com/aws-actions/configure-aws-credentials
id-token: write
env:
REGION: eu-west-3
FUNCTION_NAME: name-of-function
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- uses: axel-op/package-java-aws-lambda@main
id: package
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
aws-region: ${{ env.REGION }}
- name: Deploy on AWS
env:
JAR: ${{ steps.package.outputs.deployment-file }}
run: aws lambda update-function-code --function-name $FUNCTION_NAME --zip-file "fileb://$JAR"
```The [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/lambda-java.html) describes all the possible ways to deploy your function.