schlarpc / overengineered-cloudfront-s3-static-website

The objectively correct static website host with S3 + CloudFront
5 stars 0 forks source link

Investigate if compressed request bodies affect CloudWatch Logs ingest pricing #9

Closed schlarpc closed 2 years ago

schlarpc commented 2 years ago

Seems unlikely, but worth a look.

schlarpc commented 2 years ago

It doesn't appear to affect the IncomingBytes metric, so it's very unlikely to affect billing. Probably still worth implementing just for the network throughput savings though.

def gzip_request_body(request, **_):
    if "Content-Encoding" not in request.headers:
        request.headers.add_header("Content-Encoding", "gzip")
        request.data = gzip.compress(request.body)

logs.meta.events.register("before-sign.logs.PutLogEvents", gzip_request_body)
schlarpc commented 2 years ago

Implemented in 66d11294e10bd87aaa191f7bbeb43b92c1e66c34