Skip to content

Instantly share code, notes, and snippets.

Avatar

Drew Stokes dstokes

View GitHub Profile
@dstokes
dstokes / Dockerfile
Created Aug 24, 2017
Hello Kubernetes!
View Dockerfile
FROM alpine
COPY server.sh /srv/server.sh
EXPOSE 3000
ENTRYPOINT ["/bin/sh", "/srv/server.sh"]
@dstokes
dstokes / elb-ssl.sh
Created Jun 12, 2017
Print SSL certificate names associated with ELB & ALB
View elb-ssl.sh
#!/bin/bash
# setup ssl certificate formatter
exec 3> >(awk '$2 != "None" {split($2, a, "/"); $2=a[length(a)]; print; system("")}')
# inspect nlb
aws elb describe-load-balancers \
--query 'LoadBalancerDescriptions[].{Name: LoadBalancerName, SSLCertificate: ListenerDescriptions[?Listener.Protocol==`HTTPS`].Listener.SSLCertificateId | [0]}' \
--output text >&3
@dstokes
dstokes / main.py
Created May 31, 2017
Github to Codebuild Lambda Function
View main.py
import boto3, json
def lambda_handler(event, context):
client = boto3.client('codebuild')
for e in event['Records']:
source = e['EventSource']
if source == 'aws:sns':
message = json.loads(e['Sns']['Message'])
project = message['repository']['name']
@dstokes
dstokes / siege_urls.sh
Created Feb 13, 2017
Generate randomized urls for Siege
View siege_urls.sh
#!/bin/bash
#
# Generate random urls for Siege
#
# $1: url
# $2: count
if [[ -z $1 ]]; then
echo "Usage: $0 http://my.site 1000"
@dstokes
dstokes / wtf.sh
Last active Nov 18, 2016
Cloudtrail calls by key ID
View wtf.sh
#!/bin/bash
shopt -s lastpipe
exec 3> >(egrep '^EVENTS' | egrep -o '{.+}' | json -gac 'this.userIdentity && this.userIdentity.accessKeyId == "<UR_KEY>"')
NEXT=""
TOKEN=""
COUNT=0
while [ -n "$TOKEN" ] || [ $COUNT -eq 0 ]; do
test -n "$TOKEN" && NEXT="--next-token '$TOKEN'"
@dstokes
dstokes / dns-check.sh
Created Nov 7, 2016
Test Dead Route53 DNS Records
View dns-check.sh
#!/bin/bash
DOMAIN=$1
PORT=$2
TYPES=(A CNAME)
# resolve zone id
ZONE=$(aws route53 list-hosted-zones --query 'HostedZones[?Name==`'$DOMAIN'.`].Id' --output text)
if [[ -z "$ZONE" ]]; then
echo "Unrecognized domain: $1" >&2
View letsencrypt-renew.sh
#!/bin/bash
#
# Update SSL certs with letsencrypt
#
LE_HOME=/usr/src/letsencrypt
# stop nginx temporarily
echo "Stopping nginx"
View pgp-transition-statement-20151215.txt
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I am transitioning to a new GPG key. I have no reason to believe my
old key has been compromised and it will continue to be valid for some
time.
This transition document is signed with both keys to validate the
transition.
@dstokes
dstokes / reInvent_notes.md
Last active Oct 9, 2015
re:Invent 2015 Notes
View reInvent_notes.md

Amazon WAF (Web Application Firewall)

  • Configured against Cloudfront distributions
  • Filters:
    • IP
    • string matching against requests
    • SQLi
  • 1 minute rule propagation
  • 1 minute metrics
  • Allow, Deny and Record requests
@dstokes
dstokes / index.js
Created Apr 10, 2015
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var _ = require('lodash');
// shuffle the things
function shuffle(list) {
var len = list.length
, result = Array(len)
;
for (var i = 0; i < len; i++) {
You can’t perform that action at this time.