Skip to content

AWS serverless API for generating meme(s) and some basic frontend

Notifications You must be signed in to change notification settings

kutzowsky/Memiarka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memiarka

AWS serverless API for generating meme(s) like this one below + some basic frontend to use it.

Sample meme image

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.

How to use it?

I just want to run it

Deployed version should be available here. (Warning, some polish ahead, but you'll manage.)

I want to deploy it myself

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.

How it works

  1. Frontend does GET call with two meme text lines, e.g.: https://API.URL/function?firstLine=Chmura?&secondLine=A na co to komu?

  2. Call goes to the API Gateway which forwards it to Lambda function

  3. Lambda function gets meme template and font from INPUT_BUCKET, uses Pillow to add meme text and then saves it to OUTPUT_BUCKET.

  4. Caller gets URL to the produced image in JSON response.

{"memeUrl": "https://OUTPUTBUCKET.s3.amazonaws.com/93869b4a-d57e-4c00-a06a-7ca471de721c.png"}

Requirements

Known issues and limitations

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's app.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 and OUTPUT_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.

Trivia

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!

About

AWS serverless API for generating meme(s) and some basic frontend

Topics

Resources

Stars

Watchers

Forks