
Weekend Creative Agent Challenge: AstroMuse
What happens when an AI starship captain wakes up every day to look at the real universe? Learn how to build an always-on, memory-driven creative agent entirely on the AWS Free Tier.
Live site: < http://astromuse-686112930486.s3-website-us-east-1.amazonaws.com>
Repo: < https://github.com/mahanteshimath/aws-builder-Challenge-Aug-21>
Vision and what it does
The best tool is the one you never have to open. That line from the challenge brief
became the whole design constraint for AstroMuse.
Space data is genuinely thrilling and almost always presented as though it isn't. NASA
publishes an Astronomy Picture of the Day every single morning — a real photograph of a
real object, with a paragraph of real astrophysics attached — and for most people it
lands as another unread tab. Meanwhile every creative AI app I have built has the same
flaw: it sits there, inert, waiting for a human to press Generate. The moment you stop
pressing, the app is dead.
AstroMuse is my attempt to remove the button entirely. Every morning at 12:00 UTC it
wakes up on its own, fetches today's real APOD, looks at the photograph with a vision
model, and writes a three-paragraph starship captain's log grounded in what it actually
saw and in the real astrophysics NASA supplied. It draws itself a retro 1970s pulp
magazine cover, publishes the whole thing as a web page, and goes back to sleep. Nobody
asks it to. There is no UI. You just open the page with your coffee and yesterday's
universe has already been turned into fiction.
The part I care about most is the memory. Before writing, the agent reads its own last
three entries back out of S3 and pulls forward a one-line note describing each entry's
stylistic quirk, with an instruction to let the voice drift a little further today.
So the captain is not a fresh stateless prompt every morning — the voice compounds. Over
a week the logs get noticeably more clipped and stranger. The agent is not just always
on; it is slowly becoming someone.
How I built it
The first decision was made for me. I planned to use Amazon Nova Canvas for the artwork,
and my first
InvokeModel call came back with ResourceNotFoundException: This Model is
marked by provider as Legacy . Titan Image Generator was not in the account's model list
at all, and the Stability text-to-image models in us-west-2 returned an
AccessDeniedException for missing aws-marketplace:Subscribe permissions. Ten minutes
in, my image pillar was gone.Rather than spend the weekend chasing model access, I inverted the problem. NASA already
supplies a genuinely spectacular image every day — I did not need to generate one, I
needed to understand one. So Nova Lite reads the actual APOD photograph as a multimodal
input and describes its shapes, colours and mood, and that description becomes grounding
for Nova Micro's log. For the retro cover, I asked Nova Micro to emit raw SVG. Code as
art. It turns out a small, cheap text model is a perfectly decent poster designer if you
constrain it to a fixed
viewBox and a whitelist of shape elements.Two things bit me and both were about trusting model output too much.
First, I asked Nova Micro to reply in JSON and it dropped a comma between two keys.
json.loads threw, my fallback fired, and the site published a raw JSON blob as prose.
I replaced JSON with a plain labelled block — STARDATE: , TITLE: , VOICE: , LOG: —
parsed with one regex. Small models drop punctuation constantly but almost never mangle a
line-leading ALLCAPS label. That single change took the format failure rate to zero.Second, and more seriously: I was about to embed model-authored SVG directly into my
HTML. An LLM writing markup that lands unescaped on a public page is a stored XSS vector
with extra steps. The fix was two layers. The SVG is written to its own object and
embedded with
\<img src="..."\> , which stops browsers executing script inside it, and
sanitize_svg() rejects any output containing \<script\> , \<foreignObject\> , \<use\> ,
javascript: or an on*= attribute, falling back to a hand-written cover instead. Every
model and API string reaching the page goes through html.escape() . There is a small
assert-based self-check that fires if any of that regresses.I also skipped SAM and CDK. The whole stack deploys from one idempotent
deploy.py
using boto3 — no Docker, no CloudFormation stack to debug at 2am. The Lambda uses only
urllib and boto3 , so there are zero dependencies to package.AWS services used and architecture overview
EventBridge cron(0 12 * * ? *)
|
v
Lambda (Python 3.13, 512 MB, 180 s)
|-- NASA APOD API .................. today's real image + facts
|-- Bedrock: amazon.nova-lite-v1:0 .. vision, looks at the photo
|-- S3 GET logs/ ................... reads its own last 3 entries (memory)
|-- Bedrock: amazon.nova-micro-v1:0 . writes the log, then draws the SVG cover
v
S3 static website
index.html | archive/\<date\>.html | covers/\<date\>.svg (public)
logs/\<date\>.json (private)- Amazon EventBridge — the only trigger. One daily cron rule.
- AWS Lambda — the whole agent, one file, no layers, no dependencies.
- Amazon Bedrock — Nova Lite for vision, Nova Micro for prose and SVG.
- Amazon S3 — static website hosting and the agent's memory store.
- AWS IAM — a scoped role:
bedrock:InvokeModelon exactly two model ARNs, S3 on exactly one bucket. NoFullAccessanywhere.
The bucket policy is worth a note. Only
index.html , archive/* and covers/* are
public. The logs/ prefix — the agent's memory — is readable by the Lambda role and
nobody else, and I verified that with a 403 from the public URL.What I learned
Model availability is a design input, not a detail. I assumed the image models in
every tutorial would be there. Half of them were legacy-blocked or behind Marketplace
permissions my IAM user did not have. Ten minutes of
list-foundation-models and a
throwaway invoke_model up front would have saved me an architecture. Now I check
before I design.The constraint made it better. A generated spaceship picture is what everyone else
has. A model that looks at the actual telescope photograph and writes about what it sees
is a different, more honest thing — and giving the SVG job to a text model produced a
weirder, more charming cover than a diffusion model would have.
Structured output from small models wants structure, not JSON. Labelled lines beat
JSON schemas when the model is cheap.
Statelessness is what makes agents feel fake. Adding one
list_objects_v2 and three
get_object calls — maybe fifteen lines — is the difference between a cron job that
generates text and something that reads like it has been out there a while.Total cost: pennies a month. Nova Micro is roughly $0.000035 per 1K input tokens, the
Lambda runs for about 20 seconds a day, and S3 holds a few kilobytes. It will run
unattended for a year on the Free Tier.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article