- Create a new CloudFormation stack using cloudformation.template.
- Upload example-s3-object.json to the S3 bucket (link in "Resources" tab of CloudFormation stack).
- Go to Lambda console for function (again, link in "Resources" tab of CloudFormation stack).
- Invoke Lambda function with test event containing lambda-test-event.json.
- Output contains a S3 signed URL in the
s3
and its CloudFront equivalent in thecf
property. - Use a browser or something like Postman to GET the
cf
URL. - Confirm the response was compressed by checking the
Content-Encoding
header forgzip
orbr
.
Notes:
- The S3 object can be accessed directly from the bucket using the
s3
URL. - There is no way to determine the
s3
URL from thecf
URL. - CloudFront only compresses files with a
Content-Type
header value listed here. - CloudFront only compresses files that are between 1,000 bytes and 10,000,000 bytes in size.
- Read Serving compressed files for more information.