Some of the stuff we do: - rewrite urls - auth and permissions check - serve index.html on directory indexes - inject dynamic content in served html files - add CORS headers
> When you’re working with the HTTP response, Lambda@Edge does not expose the body that is returned by the origin server to the origin-response trigger. You can generate a static content body by setting it to the desired value, or remove the body inside the function by setting the value to be empty. If you don’t update the body field in your function, the original body returned by the origin server is returned back to viewer.
https://docs.aws.amazon.com/AmazonCloudFront/latest/Develope...
> If you are using an AWS origin, effective December 1, 2014, data transferred from origin to edge locations (Amazon CloudFront "origin fetches") will be free of charge.
And in general data out from CloudFront ($0.085 to $0.02 in NA & EU) is cheaper than data out from S3 ($0.09 to $0.05 in us-east-2). For the lambda@Edge portion it's $0.60 per 1 million requests while the CloudFront requests are $0.75 to $1.00 per 1 million requests.
Those are public on demand rates and any customers with significant or consistent usage should definitely contact AWS for lower committed/custom prices.
Edit: Disclaimer I'm a principal at AWS, and in the past spent significant time working on CloudFront & Lambda@Edge, but all of the above is public information.
This makes lambda's the glue of AWS. The input events are small json values, and the outputs are json values, and you can (mostly) use any language you want.
From a customer point of view, maybe you need to rewrite the path based on the contents of a cookie, or maybe you want to shed certain types of requests in high load scenarios, or maybe there's a buggy upstream application that sends bad cache-control headers, or ...
If the goal is to let the customer specify infinitely complex logic at the edge, a programming language is a good way to do that. Function As A Service is a good billing model for lots of invocations of short, small functions across the customers choice of language.
We experimented with using Lambda@Edge for manipulating a header, but the added latency just wasn't worth it, and we had to come up with a different solution. That was years ago though, so maybe it is better now.
In that phase you can change anything about the request itself, or the origin it will connect to. But the function only needs to run when there's a cache miss.
I have an application that needs to select an origin based on the request path (too many to use CloudFront cache behaviours), with a cache miss rate of less than 1%. It's a tiny amount of additional latency for cache misses, and a very small proportion of our CDN costs per month.
I caught it too. I get downvoted a lot for not following rules and I don’t really care this was hilarious
but by allowing JS/whatever, it gives you an infinite landscape to work with the values in a language that a wide range of people grok.
it's just a matter of getting a decent deployment setup so you can rinse and repeat easily.
but i agree, it's a freaking jack hammer where most people need a small tack hammer.
These are executed. Lambda is just a brand name. We did this 15 years ago on hardware load balancers, proxy servers, cache servers etc
Then why a (Turing-complete) programming language and not a config language? Simple: because a programming language gives you infinite more power than what any config system could ever provide. E.g. I could compare the origin IP, determine the country, and change the response based on that. And there are plenty of use cases like this which you cannot express in a config language.
Well, you can do that in plenty of "config languages", including nginx[1]. The reason Lambda exists is that it's good for Amazon, because they can push all the costs of the logic back onto the customer. (It could also be good for the customer, in that whatever configuration Amazon might otherwise support could be limited.)
[1] http://nginx.org/en/docs/http/ngx_http_geoip_module.html
Cloudfront is a CDN, it's not intended to be a replacement for nginx.
I'm not knowledgeable AT ALL in this area, having never used or first-hand seen these FAAS things.
But header manipulation? Really... These are executed as aws lambdas?! I don't get why you'd ever need to do this.
(Not being facetious, honest puzzlement!)