https://github.com/alehatsman/clj-lambda-graphviz-s3
Example of using graphviz in s3 using clojure
https://github.com/alehatsman/clj-lambda-graphviz-s3
aws-lambda aws-s3 clojure graphql
Last synced: 10 months ago
JSON representation
Example of using graphviz in s3 using clojure
- Host: GitHub
- URL: https://github.com/alehatsman/clj-lambda-graphviz-s3
- Owner: alehatsman
- License: epl-1.0
- Created: 2017-08-23T14:31:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-07T20:17:08.000Z (over 8 years ago)
- Last Synced: 2025-02-05T01:43:46.529Z (11 months ago)
- Topics: aws-lambda, aws-s3, clojure, graphql
- Language: Clojure
- Homepage:
- Size: 2.01 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# clj-lambda-graphviz-s3
In this project, my goal is to create an aws lambda function, which performs dot graph rendering in the cloud.
I use Clojure for function implementation. That function takes graph description, generates graph using c binary library "Graphviz" and saves graph to S3 storage.
I used my lambada library for AWS Lambda integration, clojure.java.shell to call graphviz executable.
My plan was:
1. Buuild Graphviz executable binary, that i can run in AWS Lambda environment.
2. Place binary under resources, so it will be packed into uberjar.
3. During runtime, copy binary under /tmp folder in AWS Lambda.
4. Run graph generation to temp file.
5. Put file to s3 and remove temp file.
## How to build Graphviz with pdf support.
We use graphviz library. We have to compile graphviz in the same platform, that we going to use to run it. (AWS Lambda) I have rent EC2 instance and compiled library in it.
```
$ // Rent ec2 instance.
$ // Connect to it using ssh.
$ yum groupinstall "Development tools" // that will install C compiler and delepment tools.
$ sudo yum install cairo-devel pango-devel // that dependencies required for PDF format.
$ wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.40.1.tar.gz
$ tar -xvf graphviz-2.40.1.tar.gz
$ cd graphviz-2.40.1
$ ./configure
$ make
$ cd cmd/dot
$ make dot_static
// To copy file from ssh to your local machine use next command
$ scp ec2-user@.eu-central-1.compute.amazonaws.com:/home/ec2-user/graphviz/graphviz-2.40.1/cmd/dot/dot_static ./
```
## Execute graphviz using clojure.shell
The problem i faced is how to install graphviz in AWS Lambda environment. Because you do not have access to machine itself. What i decided to is to generate graphviz binary, place it under resources, and then copy under /tmp folder. From there we can call it as binary executable.
To execure graphviz binary i use [clojure.java.shell](https://clojure.github.io/clojure/clojure.java.shell-api.html). For that purpose i generate sh script and feed it to sh function.
## License
Copyright © 2017 Aleh Atsman
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.