Skip to content

Instantly share code, notes, and snippets.

@flackjap
flackjap / cf-s3-access-policy.json
Created Oct 18, 2020
CloudFront Origin Access Bucket Policy
View cf-s3-access-policy.json
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E336V70R8E3QKE"
},
@flackjap
flackjap / lambda-auth-cloudefront.js
Created Oct 18, 2020
AWS Lambda@Edge Basic Auth for CloudeFront in front of S3
View lambda-auth-cloudefront.js
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'my-s3-username';
const authPass = 'my-s3-password';
@flackjap
flackjap / object-watch.js
Last active Nov 8, 2019 — forked from eligrey/object-watch.js
Fork of object.watch polyfill in ES5. Modified to not react when the value set is the same as previous.
View object-watch.js
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
*
* Modified by Nenad Damnjanović
* Nov 9, 2014