AWS Builder Center
Weekend Creative Agent Challenge: Story at Sunset

Weekend Creative Agent Challenge: Story at Sunset

An always-on AWS agent turns Islamabad’s date and evening weather into a fresh, illustrated bedtime story. EventBridge Scheduler, Lambda, Amazon Bedrock, and layered budget controls keep it autonomous and affordable.

Weekend Creative Agent Challenge: Story at Sunset

Vision & What It Does

Story at Sunset is an always-on creative agent that prepares an original illustrated bedtime story for Islamabad every evening. Families do not open a writing tool, compose a prompt, or wait for generation; tonight's story is already waiting when they visit.
The agent combines the local date, season, current evening weather, and summaries of its seven latest stories. Amazon Nova Micro uses that context to write a calm, family-friendly short story and structured art direction. Lambda turns the validated palette and normalized motif into a matching SVG landscape. The recent-story context helps preserve a recognizable voice while reducing repetition across characters, settings, plots, and motifs.
The reader presents the newest story first and keeps previous editions in a dated archive. Editions include weather, reading time, a gentle thought, illustration, run metadata, and estimated model cost. Users can copy, download, or print, but cannot start production generation. The public site is where people can access the creative work.
Preview:


How You Built It

I built the workflow locally, targeting Lambda's Node.js 22 runtime. A deterministic mock provider, file-backed repository, and generated SVG art require no AWS credentials or paid calls. The development server ensures today's mock edition on startup and starts a local schedule poller that exercises the same orchestration. This supported development of the reader, archive, date locking, and failure states before connecting cloud resources. Tests cover configuration bounds, handlers, provider parsing, spend reservations, pause behavior, and same-date reuse.
The production path is separate. EventBridge Scheduler is configured to invoke the generator Lambda daily at 6:30 PM  Asia/Karachi . Lambda records schedule and run metadata with the story. The agent checks for an existing edition, atomically reserves monthly allowance in DynamoDB, checks the pause state, fetches Islamabad weather from Open-Meteo, and loads recent stories. A bounded weather request falls back to date and season context instead of stopping the run.
Nova Micro must return strict JSON containing the story, presentation metadata, palette, motif, alt text, and art direction. The provider validates and normalizes it and limits output to 1,400 tokens by default. After another pause check, a small renderer creates a 1280x720 SVG using only validated colors and fixed shapes. The agent stores art privately in S3 and the story in DynamoDB.
A DynamoDB transaction checks the global pause, acquires the local-date lock, and reserves monthly allowance as one operation. A distinct run ID cannot acquire a date that another run owns. Scheduler delivery retries are bounded, and Lambda retries a failed asynchronous execution once with the same stable run ID and reservation. An explicit Lambda failure destination then retains an exhausted event in encrypted SQS. Lambda emits a JSON-formatted  story-generation-result  CloudWatch message so an autonomous run can be verified without exposing prompts, credentials, or personal information.
Cloud validation exposed two problems that local mocks could not: the DynamoDB transaction needed an explicit  ConditionCheckItem  IAM action, and Nova Canvas had become Legacy and unavailable for new use in this account. I added the missing least-privilege action and replaced the unavailable image dependency with the Nova-directed SVG renderer. The latter reduced both model cost and lifecycle risk while keeping the daily output illustrated.
For genuine autonomous evidence, I temporarily moved the enabled schedule earlier, waited without manually invoking Lambda, and then restored the normal 6:30 PM schedule through CloudFormation. EventBridge scheduled the successful edition for  2026-08-21T12:33:00Z ; Lambda published it 23 seconds later. The matching sanitized API and CloudWatch fields were:
{
"event": "story-generation-result",
"status": "created",
"title": "The Firefly Festival in Islamabad",
"scheduledFor": "2026-08-21T12:33:00Z",
"runId": "story-at-sunset-2026-08-21T12:33:00Z",
"trigger": "eventbridge-scheduler",
"storyModel": "amazon.nova-micro-v1:0"
}

AWS Services Used / Architecture Overview

One AWS SAM template defines the backend infrastructure for  us-east-1 . Amplify Hosting is configured separately with the checked-in  amplify.yml  build specification.
  • Amazon EventBridge Scheduler starts the creative workflow each evening without user action.
  • AWS Lambda runs three focused functions: story generation, read-only delivery, and budget-triggered stopping.
  • Amazon Bedrock provides Amazon Nova Micro for low-cost story writing and structured art direction.
  • Amazon DynamoDB stores stories, local-date locks, the monthly reservation ledger, and the global pause flag using on-demand billing.
  • Amazon S3 stores generated art with encryption and Block Public Access enabled. The read function returns short-lived signed URLs rather than exposing the bucket.
  • Amazon API Gateway exposes only  GET /stories  and  GET /health , with read throttling. There is no production generation endpoint.
  • AWS Amplify Hosting serves the static reader and injects the read API URL at build time.
  • Amazon CloudWatch retains Lambda and API logs, including a JSON-formatted generation result, while Amazon SQS provides the encrypted dead-letter queue.
  • AWS Budgets and Amazon SNS provide account-level Bedrock monitoring and invoke the budget-stop Lambda.
The data flow is:

The generator role can invoke only the named Nova Micro foundation model. The reader role cannot invoke Bedrock or write stories. Browser code receives neither AWS credentials nor S3 permissions.
The normal workload is one short text generation daily; SVG rendering adds no model call. At rates encoded during development, normal model use is expected to stay well below $1 monthly, while other AWS costs depend on read traffic and current service pricing. Before calling the model, the application still reserves a deliberately conservative $1.45 allowance. At most 31 monthly reservations total $44.95, so the reservation ledger cannot exceed its $45 ceiling. This is a conservative allowance, not measured AWS spend.
Separately, the SAM stack defines a $50 monthly AWS Cost Budget filtered to Amazon Bedrock. After reported actual spend exceeds 90%, SNS invokes the stop function and sends another signal after spend exceeds 100%; the function writes a global pause flag, so later scheduled runs exit before invoking Bedrock. An optional confirmed email subscription can receive the same notifications. This is not an exact real-time $50 hard cap. AWS Budgets relies on delayed billing data; the budget includes other Bedrock use in the account; and the stop function can pause only this application. The immediate $45 reservation ledger, local-date lock, stable retry IDs, token limit, bounded retries, and restricted IAM are therefore the primary controls. The ledger and AWS Budget reset monthly, but a global pause remains until the owner reviews the spend and deliberately resumes generation; none of these is a lifetime account-spend limit.

What You Learned

The most useful shift was treating an agent as a dependable publisher instead of a chat interface. Removing public generation simplified the reader experience and spend model: public requests only read existing work, while the scheduled path owns every paid action.
I also learned that creative continuity does not require an expensive memory system. Supplying compact summaries of the latest stories gives Nova Micro enough context to avoid obvious repetition while keeping input small. Weather adds a fresh daily constraint, and a seasonal fallback ensures that an unreliable external request does not make the agent miss its edition.
Finally, budgets and application controls solve different problems. AWS Budgets is valuable for account-level visibility and an automated stop signal, but delayed cost data means it cannot promise a precise cutoff. A conservative reservation ledger inside the transaction boundary responds immediately. Using both layers, and being explicit about their limits, is safer than describing a billing alert as a hard cap.

Link to App or Repo

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article