Skip to content

Instantly share code, notes, and snippets.

@gillisandrew
gillisandrew / RequestIntegration.vtl
Last active October 20, 2020 22:46
Short request integration for AWS API Gateway mock integration. For use on the OPTIONS method to support CORS.
#set($origin = $input.params().get('header').get('Origin'))
{
## TODO: update regex to match your supported API origins
#if($origin.matches("https?:example.com"))
"statusCode": 204
#set($context.responseOverride.header.Access-Control-Allow-Origin = $origin)
#set($context.responseOverride.header.Access-Control-Allow-Methods = "OPTIONS,GET,PUT,POST,DELETE,PATCH,HEAD")
#set($context.responseOverride.header.Access-Control-Allow-Headers = "Authorization,Content-Type,Accept")
#set($context.responseOverride.header.Access-Control-Max-Age = "86400")
#else
#!/usr/bin/env bash
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$3" == "0" ]]; then
# Exit gracefully when hook is called on file checkout
exit 0
fi
if [[ "$BRANCH" == "" ]]; then
# Error when the branch could not be determined
echo 'ERROR: Unable to determine the current branch'
exit 1
#! /usr/bin/env python3
import boto3
def create_billing_alarm(account, amount, topic):
"""Creates a billing alarm for a linked account.
Parameters
----------
account : str
Account ID of the linked account.