Weekend Creative Challenge: Pujangga (Poem Generator)
Your AI Indonesian wordsmith: turn any theme into a pantun, a cheesy gombal, rap bars, an aesthetic caption, or a short puisi, written in seconds by Amazon Bedrock (Nova). It even replies to your pantun, and every creation joins a shared wall. Serverless on Lambda, API Gateway, DynamoDB & Bedrock.
Vision & What the App Does
Indonesian culture runs on wordplay. A pantun (a four-line Malay poem with a strict
A-B-A-B rhyme) opens weddings and speeches; a gombal (a cheesy pick-up line) is how you
make someone laugh on a bad day; a sharp caption carries an Instagram post; rap and
free-verse puisi are how a lot of us actually process our feelings. All of it is fun, and
all of it is a little hard to do well on the spot.
Pujangga ("bard/poet") is a tiny AI wordsmith for exactly those moments. You pick a form,
pantun, gombal, rap bars, caption, or puisi, type a theme ("long-distance love",
"Monday", "learning AWS"), choose a mood (Funny / Romantic / Wisdom / Hype), and Amazon
Bedrock writes it instantly. The creative output is the product: a short, shareable piece
of Indonesian writing meant to make someone smile.
Two touches keep it playful. A pantun berbalas mode lets you paste a pantun and get a
matching reply pantun back, recreating the traditional call-and-response. And a shared
wall shows the latest creations from everyone who visits, so it feels like a communal
notebook rather than a one-shot toy.
How I Built It
I started narrow, just pantun, and the most important early lesson came fast: the model
happily wrote four themed lines but ignored the A-B-A-B rhyme. Piling on rules ("8–12
syllables", "rhyme like this") barely helped. What worked was a single embedded example:
I put a classic pantun in the system prompt ("Kalau ada sumur di ladang / Boleh kita
menumpang mandi…") and pointed out which word rhymes with which. Anchoring the model to one
concrete exemplar pulled the rhyme far closer than any abstract instruction, the clearest
few-shot-prompting win I've personally seen.
That insight shaped the whole architecture. Since a "form" is really just a system prompt
plus a line count, I made all five forms share one Bedrock Converse call and one parser.
Adding gombal, rap, caption and puisi was writing four prompts, not four features, the app
grew in creativity without growing in complexity. A shared parser strips numbering and stray
quotes down to clean lines, and temperature sits at ~0.9 so tapping the same theme twice
gives you something new.
The backend is a single AWS Lambda behind API Gateway, with DynamoDB behind the wall; the
static frontend lives on Amplify Hosting. To make that split feel like one app I put a
CloudFront distribution in front of both, so everything is same-origin behind one domain and
one WAF. One recurring snag on this account: a Lambda Function URL is blocked by an
Organization SCP, so the API entry point is an API Gateway HTTP API, a drop-in swap since its
v2 payload is identical.
AWS Services Used / Architecture Overview
AWS WAF (managed rules + per-IP rate limit) | Browser --> Amazon CloudFront -------+--> AWS Amplify Hosting (static frontend) +--> Amazon API Gateway (HTTP API) --> AWS Lambda (Node 22) |--> Amazon Bedrock, Nova Lite (+ Guardrails) +--> Amazon DynamoDB (shared wall) IAM (least-privilege) . CloudWatchOne CloudFront distribution fronts everything: the default path serves the frontend from
Amplify Hosting, while
/api/* routes to API Gateway. Because both sit behind the
same distribution it is all same-origin (no CORS), and a single AWS WAF web ACL protects
the whole app. Each creative form is just a different system prompt over one Bedrock Converse call.- Amazon Bedrock (Nova Lite + Guardrails): the poet, plus a managed guardrail that keeps it on-task.
- AWS Amplify Hosting: serves the static frontend.
- Amazon CloudFront + AWS WAF: single public entry point with managed rules and rate limiting.
- Amazon API Gateway (HTTP API) + AWS Lambda: the JSON API; one Node function, forms as prompts.
- Amazon DynamoDB: on-demand table backing the shared wall.
- IAM + CloudWatch: least-privilege role and logs.
To stop anyone bypassing the WAF by hitting API Gateway directly, CloudFront injects a secretheader the Lambda verifies, rejecting requests that do not come through the distribution.Everything is serverless and pay-per-use, defined end-to-end in Terraform.
Keeping the AI On-Task (Guardrails)
A creative app still needs guardrails, so Pujangga uses two layers. The system prompt is
hardened to treat the user's theme as untrusted subject text, never as instructions, and to
only ever emit the requested Indonesian form. On top of that, an Amazon Bedrock Guardrail
blocks prompt-injection attempts, harmful content, and a denied "general assistant" topic. Ask
it to reveal its prompt, write code, or answer "what is the capital of France?" and it politely
refuses; ask for a pantun about heartbreak and it delivers. Off-topic in, nothing out.
What I've Learned
Two lessons stuck. First, for structured creativity a single good example beats a page of
rules, one exemplar pantun did more for rhyme than every constraint I could phrase.
Second, prompts are a scaling unit: because each creative form was just another system
prompt over the same call, going from a one-trick pantun app to a five-form studio cost
almost no new code, the interesting variety lived entirely in language, not plumbing.
I also hit an honest limit worth sharing: I wanted an image-generation form too, but the
image models in this account were legacy/retired, so I leaned into what Nova Lite does
brilliantly, Indonesian text, instead of forcing a half-working feature. And I came away
appreciating that "creative" doesn't mean "unstructured": a pantun's rigid rhyme, a gombal's
punchline shape, a caption's brevity, those constraints are exactly what make the output
feel crafted. Turning five beloved Indonesian forms into one-tap creations, and watching it
fire back a reply pantun, was the most fun I've had with an LLM in a while.
Link to Repo & Demo
- Source code (GitHub): https://github.com/yogaics/pujangga-ai.git
The whole stack is Terraform in the repo,
terraform apply deploys it into any AWS account
with Bedrock Nova access.Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article