Skip to content

Instantly share code, notes, and snippets.

@antimius
antimius / find_latest_ami.sh
Last active March 19, 2018 05:04
Script to find and print the latest stable, HVM, EBS GP2 backed EC2 AMIs from major OS vendors. Requires aws-cli to be installed. Takes a long time to complete due to AWS describe-images call being slow.
#!/bin/bash
# prints latest, stable, HVM, EBS GP2 backed AMIs for major OSs
# amazon, redhat 309956199498, ubuntu 099720109477, freebsd 118940168514, CentOS marketplace code
REDHAT=309956199498
UBUNTU=099720109477
FREEBSD=118940168514
MICROSOFT=801119661308
REGION=${REGION:-"us-east-1"}
@antimius
antimius / format_changeset.py
Last active August 9, 2018 14:59
Format CloudFormation changesets in CLI
#!/usr/bin/env python
from __future__ import print_function
from terminaltables import DoubleTable
from termcolor import colored
import sys, json
def colorize(s):
colors = {
#!/usr/bin/env bash
MD5=$(curl --silent https://ip-ranges.amazonaws.com/ip-ranges.json | md5)
CF_FUNCTION_ARN=$(aws lambda list-functions | jq -r '.Functions[]|select(.Handler=="update-cloudfront-sg.lambda_handler").FunctionArn')
aws lambda invoke --function-name $CF_FUNCTION_ARN --invocation-type RequestResponse \
--payload "{\"Records\":[{\"EventVersion\":\"1.0\",\"EventSubscriptionArn\":\"arn:aws:sns:EXAMPLE\",\"EventSource\":\"aws:sns\",\"Sns\":{\"SignatureVersion\":\"1\",\"Timestamp\":\"1970-01-01T00:00:00.000Z\",\"Signature\":\"EXAMPLE\",\"SigningCertUrl\":\"EXAMPLE\",\"MessageId\":\"95df01b4-ee98-5cb9-9903-4c221d41eb5e\",\"Message\":\"{\\\"create-time\\\": \\\"yyyy-mm-ddThh:mm:ss+00:00\\\", \\\"synctoken\\\": \\\"0123456789\\\", \\\"md5\\\": \\\"$MD5\\\", \\\"url\\\": \\\"https://ip-ranges.amazonaws.com/ip-ranges.json\\\"}\",\"Type\":\"Notification\",\"UnsubscribeUrl\":\"EXAMPLE\",\"TopicArn\":\"arn:aws:sns:EXAMPLE\",\"Subject\":\"TestInvoke\"}}]}" \
lambda-output.txt
cat lambda-output.txt

Keybase proof

I hereby claim:

  • I am antimius on github.
  • I am antimius (https://keybase.io/antimius) on keybase.
  • I have a public key ASCdeu9MHKhPI4MsFUmvwWiKp2js0DGJKRaFlIjyhaS10Ao

To claim this, I am signing this object: