Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulrobello/plantuml
AWS Lambda to generate PlantUML diagrams via POST to its URL
https://github.com/paulrobello/plantuml
Last synced: about 21 hours ago
JSON representation
AWS Lambda to generate PlantUML diagrams via POST to its URL
- Host: GitHub
- URL: https://github.com/paulrobello/plantuml
- Owner: paulrobello
- License: gpl-3.0
- Created: 2024-05-06T21:22:24.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-23T01:11:17.000Z (2 months ago)
- Last Synced: 2024-11-23T02:19:21.814Z (2 months ago)
- Language: Makefile
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Plant UML lambda url to generate UML diagrams in SVG and PNG formats
## Description
This projects builds a lambda layer containing the plantuml jar file and OpenJDK JRE to run the jar file, as well as graphviz to generate additional diagram types.
It then creates a pyton lambda that uses the layer to run the plantuml jar file to generate SVG diagrams from PlantUML text.
The lambda is invoked via POST to Function URL with uml in body, and requires an API key to be passed in the header.
The lambda and its layer are built for arm64 to reduce cost.
The lambda also uses AWS hosted Lambda Powertools layer.
Due to the memory required to run the java program, and to decrease execution time, the lambda is configured with 1024MB of memory.
Average time to return a diagram from warm lambda is 5 seconds and 9 seconds for cold.
The layer and the lambda are built using docker.
The makefile has all needed targets to build and deploy the solution using only aws cli.## Usage
### Prerequisites
Create a .env file in the project root with the following keys for your deployment:
* AWS_ACCT=You must specify your aws account number
* AWS_REGION=Defaults to "us-east-1"
* API_KEY=Any key you want to use to secure the lambda. Defaults to "WootWootWoot"
* LAMBDA_NAME=Defaults to "plantuml"
* PLANTUML_VERSION=Defaults to "1.2024.3"
* LAMBDA_POWER_TOOLS_LAYER_VERSION=Defaults to "78"**Note you must assume aws creds in target AWS_ACCT before running any make targets**
### Build and deploy 1st time
```bash
make deploy
```
### Update Lambda and layer
```bash
make it-again
```### Make targets to test the lambda
These targets will create or overwrite the test-diagram.svg file with the diagram generated by the lambda.
```bash
make post-lambda-url-png
make post-lambda-url
make post-lambda-url-c4
make post-lambda-url-aws
make post-lambda-url-icons
```### CURL example
Note replace the lambda url with the one output from the:
```bash
make get-lambda-url.
```
You must also ensure the API key is correct. You can get the key with:
```bash
make get-lambda-env
```### CURL SVG example
```bash
curl -X POST https://2ysjlufldcjgubu3w7b3ts2pfy0vmfbn.lambda-url.us-east-1.on.aws/ \
-H 'Content-Type: text/plain' \
-H 'X-API-Key: WootWootWoot' \
--data-binary @./test-diagram.puml > test-diagram.svg
```### CURL PNG example
```bash
curl -X POST https://2ysjlufldcjgubu3w7b3ts2pfy0vmfbn.lambda-url.us-east-1.on.aws/?format=png \
-H 'Content-Type: text/plain' \
-H 'X-API-Key: WootWootWoot' \
--data-binary @./test-diagram.puml > test-diagram.png
```### Web
You can also use the web page to generate diagrams.
web/index.html allows you to specify your lambda url / api key and PUML diagram to generate the SVG.