Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sashee/cf_s3_signed_urls
Demonstration code how to use CloudFront with S3 signed URLs with proxy caching
https://github.com/sashee/cf_s3_signed_urls
aws cloudfront s3 signed-urls
Last synced: 21 days ago
JSON representation
Demonstration code how to use CloudFront with S3 signed URLs with proxy caching
- Host: GitHub
- URL: https://github.com/sashee/cf_s3_signed_urls
- Owner: sashee
- Created: 2019-07-31T10:07:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-16T21:55:25.000Z (about 3 years ago)
- Last Synced: 2024-04-16T18:39:35.831Z (8 months ago)
- Topics: aws, cloudfront, s3, signed-urls
- Language: HCL
- Homepage: https://advancedweb.hu/how-to-use-s3-signed-urls-with-cloudfront/
- Size: 119 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Demo code how to use S3 Signed URLs through CloudFront with proxy caching
To learn more, see [this blog post](https://advancedweb.hu/how-to-use-s3-signed-urls-with-cloudfront/).
### How it works
It creates a Lambda function behind an API Gateway that returns a HTML with an image. The image href is a signed URL for an object stored in a private bucket. There is a CloudFront distribution that proxies requests to the bucket.
The signed URL's domain is changed to CloudFront's and the distribution translates it back to the original URL. With this setup, the image is downloaded through CloudFront but uses the signing mechanism of S3.
Caching is configured on the CloudFront distribution and the signed URLs are made cache-friendly using time rounding. See [this article](https://advancedweb.hu/cacheable-s3-signed-urls/) for more info.
The result is subsequent requests to the image comes from CloudFront's cache instead of going all the way to the bucket.
![](docs/cf_hit.png)
### Prerequisites
* npm
* terraform### How to use
* ```terraform init```
* ```terraform apply```
* open the URL
* open the devtools, check "Disable cache" on the network panel, then refresh the page a few times
* ```terraform destroy```The image is from the [https://thecatapi.com/](https://thecatapi.com/).