• Skip to primary navigation
  • Skip to main content
Last Week in AWS Logo
Master your cloud costs
  • About
    • Community
    • Contact
  • Blog
  • Newsletter
  • Podcasts
    • Last Week in AWS Podcast
    • Screaming in the Cloud
    • Nominate a Guest
  • Merch
  • Resources
    • AWS Network Map
Public speaker at Business Conference.
10.25.2017

A Static Headache

By Corey Quinn
LastWeekinAWS.com exists [Editor’s note: It did exist this way at the time it was written. This is no longer true.] as a series of programmatically generated static pages that end up in…
FacebookXLinkedInReddit
Home Blog A Static Headache
Prev
Next

LastWeekinAWS.com exists [Editor’s note: It did exist this way at the time it was written. This is no longer true.] as a series of programmatically generated static pages that end up in an S3 bucket. (The generation process, while fascinating, is going to be the subject of a different blog post at some point and is out of scope for the rant upon which I’m about to embark.) To enable TLS, I slap CloudFront in front of that S3 bucket, and then restrict access on the bucket to the CloudFront distribution (I don’t leave it open to the world, as I couldn’t afford to hire Accenture to do my cloud security). So far this is standard, and everything works about like you’d expect it to.

The trouble comes in when I wanted to inject a few security headers in so I could get the A+ at SSL Labs (spoiler: I did). In a typical webserver environment, it’s not hard to tell Apache, Nginx, IIS, etc. to set a few arbitrary headers and call it a day. Since you’re reading this post, you might surmise that it’s not nearly so straighforward.

To insert a static header from CloudFront, you have to use a Lambda@Edge function in Javascript to add static headers.

Let me repeat that.

To insert a static header in CloudFront– a CDN service– you must use a freaking Javascript function to dynamically insert what you want into every godforsaken request.

It was around this point that I began screaming at my laptop and scaring the hell out of my chihuahua.

It turns out that you can only have Lambda@Edge functions in us-tirefire-1, they can only be written in Node, and they counter-intuitively need to have a trigger of “Viewer Response,” or they simply won’t work at all.

When the red haze faded, I disappointed my mother and wrote a node.js function that would inject the headers I wanted, but that’s not where the fun stopped.

As a final indignity, I now get to pay $0.91 per 1 million requests (a combination of the per-request charge plus compute time per invocation) just to add a static header.

You can’t have the trigger point to “latest.” You have to publish a version, and then rebuild the trigger. At some point I’m going to shove this into CloudFormation, Terraform, or a terrifying bash script and make this straightforward, but I’m really hoping I won’t ever have to touch this monster again.

AWS CloudFront team, if you’re out there: please let me set custom headers on response. I will send you an Edible Arrangement if you do. I’m not kidding.

Corey Quinn Headshot
by Corey Quinn

Corey is the Chief Cloud Economist at Duckbill, where he specializes in helping companies improve their AWS bills by making them smaller and less horrifying. He also hosts the "Screaming in the Cloud" and "AWS Morning Brief" podcasts; and curates "Last Week in AWS," a weekly newsletter summarizing the latest in AWS news, blogs, and tools, sprinkled with snark and thoughtful analysis in roughly equal measure.

More Posts from Corey

Back to the Blog

Infinidash: AWS’s New Observability Play Has Great Bones and a Terrible Bedside Manner

By Corey Quinn

Infinidash: AWS’s New Observability Play Has Great Bones and a Terrible Bedside Manner AWS has just released something fascinating in the form of CloudWatch Omni. I want to be upfront before I dive further: “CloudWatch Omni” is a wretched name that I will not be using, so for the rest of this article and the […]

Read Moreabout Infinidash: AWS’s New Observability Play Has Great Bones and a Terrible Bedside Manner

Reading Observability Tools? That’s a Robot’s Job

By Corey Quinn

Last Thursday Honeycomb was kind enough to hand me the closing keynote slot at O11yCon, a conference whose entire premise is that observability matters and the people in the room are the ones who would know. I used that slot to argue that the primary reader of your telemetry is no longer a human, and […]

Read Moreabout Reading Observability Tools? That’s a Robot’s Job

S3 Is Not a Filesystem (But Now There’s One In Front of It)

By Corey Quinn

I’ve been saying “S3 is not a filesystem” for over a decade. I’ve said it on stages, in newsletters, on podcasts, and directly to the faces of large company employees who were too polite to tell me to shut up before they went back to their FUSE monstrosities. It was one of those reliable truths […]

Read Moreabout S3 Is Not a Filesystem (But Now There’s One In Front of It)
Billie Holding Mail Email Subscribe Icon

Get the newsletter!

Stay up to date on the latest AWS news, opinions, and tools, all lovingly sprinkled with a bit of snark.

You’re faced with tough questions about cloud costs. You should have confident answers.
Get in touch.
  • Newsletter
  • Podcasts
  • Blog
  • Merch
  • About
  • Contact
  • Disclosures
Billie Footer
footprint-orange
© 2026 L9 Labs, Inc. All Rights Reserved.
Terms of Service Privacy Policy Cookie Policy