Skip to content

Instantly share code, notes, and snippets.

@croesus
croesus / index.js
Created April 29, 2018 15:06
CloudFront Edge Lambda redirect non-www to www
'use strict';
exports.handler = (event, context, callback) => {
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
var params = '';
if(('querystring' in request) && (request.querystring.length>0)) {
params = '?'+request.querystring;
}
@croesus
croesus / index.js
Last active December 22, 2021 12:49
AWS Cloudfront Lambda default file URL rewriter
// See https://medium.com/@chrispointon/default-files-in-s3-subdirectories-using-cloudfront-and-lambda-edge-941100a3c629
// Register this as the viewer-request trigger handler
'use strict';
exports.handler = (event, context, callback) => {
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
// Extract the URI and params from the request
var olduri = request.uri;
@croesus
croesus / ddbtablescan.sh
Last active November 5, 2024 08:52
AWS CLI scan DynamoDB table with rate limiting
#!/bin/bash
if [ "$#" -ne 6 ]; then
echo "Usage: ddbtablescan.sh <profile> <table> <attributeToFilterOn> <attributeValueToFilterWith> <maxItemsPerSec> <listOfAttributesToReturn>"
echo "e.g."
echo "ddbtablescan.sh my-profile Users company Amazon 10 firstName,lastName,email"
exit 1
fi
found=$(which aws)