A collection of ZSH aliases for executing various SDK CLIs
#!/usr/bin/env bash | |
######################################################################################################################### | |
# branch.sh is used, with arguments, to create a new branch from main that uses a slugified ADO ticket number and title # | |
######################################################################################################################### | |
# Exit immediately if a command exits with a non-zero status | |
set -o errexit | |
# Treat unset variables as an error when substituting | |
set -o nounset | |
# Fails entire pipeline if any command fails |
# A simple way of aliasing short project names to deeper working directories. | |
# - If you work on multiple machines and keep the same directory layout then this becomes very useful | |
# | |
# 1. Create a secret gist called joy.json that looks something like the following. Use your own meaningful project names and create as many entries as you need | |
# | |
# { | |
# "bookmarks": { | |
# "project1": "/full/path/to/the/project1/directory", | |
# "project2": "/full/path/to/the/project2/directory, | |
# } |
{ | |
"pages": { | |
"/products/product-1.xml": { | |
"title": "Product One", | |
"summary": "A short summary of this product", | |
"detail": "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum", | |
"price": "$9.99", | |
"modelName": "product-summary" | |
}, | |
"/products/product-2.xml": { |
(cors) { | |
@origin{args.0} header Origin {args.0} | |
header @origin{args.0} Access-Control-Allow-Origin "{args.0}" | |
} | |
sub.domain.com { | |
reverse_proxy 127.0.0.1:3000 | |
header Access-Control-Allow-Methods * | |
header Access-Control-Allow-Headers content-type | |
header Access-Control-Allow-Credentials true |
/** | |
* @description: Handler entry point. | |
* - Note AWS CloudFront Functions use a modified ECMAScript 5.1 compatible runtime and NOT NodeJS. | |
* - Use var, not const or let | |
* - Use string concatenation and not template literals | |
* - Beware that the CloudFront Functions Console editor and test environment do NOT mimic CloudFront 100% | |
* @date 2022-01-26 | |
* @param {object} event: A CloudFront Function event (expecting a Viewer Request event) | |
* @return {object}: A CloudFront response or request object (depends whether conditions allow pass through or 301 redirect) | |
*/ |
{ | |
"info": { | |
"_postman_id": "e5d286ab-6f35-46dd-a9f0-9c3c55b5db18", | |
"name": "MailChimp", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | |
}, | |
"item": [ | |
{ | |
"name": "Get lists info", | |
"request": { |
# Debug state | |
DEBUG=true | |
# MySQL configuration | |
DB_USER= | |
DB_PASSWORD= | |
DB_NAME= | |
DB_HOST=db:3306 | |
# WordPress configuration |
Implements a simple basic auth function to attach to an AWS CloudFront distribution. Note that basic auth is inherently insecure and should not be used to protect content of value. It does work well to keep search engines and crawlers out of stage websites.
- Create a new Lambda function in us-east-1 (AWS does not support @Edge functions from other regions at this time.)
- Copy the contents of index.js to the new Lambda
- Replace {your-shared-username} and {your-shared-password} with actual values
- Attach to CloudFront as a viewer request function
THIS GIST HAS BEEN DEPRECATED
AWS introduced CloudFront Functions as an alternative (but not replacement) to Lambda@Edge functions. Both have their pros and cons but for naked-domain-to-www redirection a CloudFront Function is a better choice. Please see Naked Redirector CloudFront Function for an implementation example.
Intended to run on CloudFront as Lambda@Edge, naked redirector checks the incoming hostname and if it is naked, e.g. somedomain.com and not www.somedomain.com, it will redirect to the www subdomain with preserved path and query string variables.