Skip to main content

Claude/ChatGPT Prompt to Architect S3 + CloudFront CDN Delivery

Set up S3 with CloudFront for static assets, media, and SPAs - caching strategies, OAC, security headers, and WAF hardening.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt makes the AI design an S3 + CloudFront delivery architecture for serving [content_type] for your [application_type]. It configures [bucket_name] with versioning, [encryption_type] encryption, lifecycle rules for [lifecycle_strategy], and blocked public access; sets up a CloudFront distribution with OAC and [cache_behaviors] behaviors (including [media_cache_ttl] for media); configures [domain] with ACM and Route 53; adds a security-headers policy; creates a CI/CD invalidation step for [invalidation_paths]; optimizes cost with compression and [price_class]; enables logging to [log_bucket]; and attaches WAF with [waf_rules].

The structure works because it treats the bucket as private and serves everything through CloudFront via Origin Access Control, which closes the public-bucket hole most leaky setups have. Getting cache behaviors and the security-headers policy right the first time avoids the cache-busting and header-rewrite cleanup common on inherited projects. Tailoring the design to [content_type] and [application_type] matters because a React SPA with user uploads needs different cache and lifecycle rules than a purely static site, and the prompt accounts for that split rather than treating all assets the same.

When to use it

  • You are putting a CDN in front of an app's static assets or a single-page build.
  • You want the origin bucket fully private with access only through CloudFront via OAC.
  • You need distinct cache behaviors for static assets, dynamic content, and media with [media_cache_ttl].
  • You need a security-headers response policy (CSP, HSTS, X-Frame-Options) applied at the edge.
  • You want a CI/CD step that invalidates [invalidation_paths] on every deploy so users get fresh files.
  • You need WAF protection with rate limiting and [waf_rules] in front of public content.

Example output

Expect an architecture spec covering the S3 bucket config (versioning, [encryption_type], lifecycle, public-access block), the CloudFront distribution with OAC and [cache_behaviors] cache behaviors, a custom-domain setup with ACM and Route 53, a response-headers policy, a CI/CD invalidation snippet for [invalidation_paths], cost settings (compression, [price_class], Intelligent Tiering), access-logging to [log_bucket], and a WAF web ACL with [waf_rules].

Pro tips

  • Use OAC and block all public access on [bucket_name]; serving a public bucket directly is the leaky-bucket pattern this design exists to avoid.
  • Set cache behaviors deliberately — long TTLs for fingerprinted static assets, no-cache for HTML, and [media_cache_ttl] for media — so deploys are not served stale.
  • Invalidate only [invalidation_paths] that actually change (like /index.html), not /*, since broad invalidations cost more and undercut caching.
  • Define the security-headers policy as a reusable CloudFront response-headers policy rather than setting headers per-origin, which is easier to audit.
  • Match [price_class] to where your users are; PriceClass_100 is cheaper but excludes some regions, so do not pick it if you serve a global audience.
  • Use [lifecycle_strategy] to transition old media to cheaper storage classes, but confirm retrieval latency from Glacier is acceptable for your access pattern.
  • Enable access logging to [log_bucket] from the start; reconstructing traffic patterns or debugging a cache-hit problem is far easier with logs you already have than ones you wish you had turned on.

Frequently Asked Questions

Does this keep my S3 bucket private?
Yes — it blocks all public access on `[bucket_name]` and serves content only through CloudFront using Origin Access Control. That closes the public-bucket exposure that many ad-hoc setups leave open, since the bucket is never reachable directly.
How does cache invalidation work on deploys?
It adds a CI/CD step that invalidates `[invalidation_paths]` — typically /index.html and hashed asset paths — on each deployment. Invalidating only what changes rather than /* keeps costs down and preserves cache hits for unchanged files.
Can I serve media and static assets with different cache rules?
It configures `[cache_behaviors]` cache behaviors so static assets get long TTLs, dynamic content is not cached, and media uses `[media_cache_ttl]`. Matching TTLs to content type is what prevents serving stale HTML while still caching immutable assets aggressively.
Does it add security headers and WAF protection?
It adds a response-headers policy with CSP, HSTS, X-Frame-Options, and X-Content-Type-Options, plus an AWS WAF web ACL with rate limiting and `[waf_rules]`. The headers harden the browser side while WAF filters malicious traffic at the edge.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in AWS & Cloud Architecture Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support