AWS serverless API for generating meme(s) like this one below + some basic frontend to use it.
There are some moments in life when Angry Pingu is my spirit animal. When those moments combine with the desire to learn Pillow library and some AWS - this happens.
Deployed version should be available here. (Warning, some polish ahead, but you'll manage.)
Frontend is just static webpage, so anything which can serve some HTML with JS and some CSS would be ok.
Backend can be deployed to AWS using SAM CLI using:
sam build --use-container
sam deploy --guided
Hovewer, some manual tweaks are required. See Known issues and limitations section.
There's an option to run and test it locally. Please refer to SAM documentation.
-
Frontend does GET call with two meme text lines, e.g.:
https://API.URL/function?firstLine=Chmura?&secondLine=A na co to komu?
-
Call goes to the API Gateway which forwards it to Lambda function
-
Lambda function gets meme template and font from
INPUT_BUCKET
, uses Pillow to add meme text and then saves it toOUTPUT_BUCKET
. -
Caller gets URL to the produced image in JSON response.
{"memeUrl": "https://OUTPUTBUCKET.s3.amazonaws.com/93869b4a-d57e-4c00-a06a-7ca471de721c.png"}
Because project is still in development, there are some loose bits and pieces:
- only Angry Pingu memes are supported right now,
- error handling in backend code improvement.
Things that needs to be done manually:
API_URL
in frontend'sapp.js
,- input and output bucket creation,
- input bucket needs to be populated with
backend/static
directory contents, - output bucket objects need to be public,
- setting object lifecycle rules for output buckets is recommended,
- lambda execution role permissions to buckets mentioned above,
INPUT_BUCKET
andOUTPUT_BUCKET
environment variables for lambda function (bucket names, not ARNs),- update CORS allow origin in lambda code.
... and that's all. Sorry, still learning SAM and CloudFormation.
Memiarka is made up polish word which can mean meme generator (person or machine, female). For example, there is kucharka - female cook, tokarka - lathe and kolarka - female cyclist or sometimes road bike (depending on the context). Learn polish, it's fun!