Skip to content

Instantly share code, notes, and snippets.

View tomislacker's full-sized avatar

Ben Tomasik tomislacker

View GitHub Profile
@tomislacker
tomislacker / unused_security_groups.sh
Last active July 25, 2018 16:33
Find Unused Security Groups.sh
#!/bin/bash
find_all_groups ()
{
aws ec2 describe-security-groups \
--query 'SecurityGroups[*].GroupId' \
--output text \
| tr '\t' '\n' \
| sort -u
}
@tomislacker
tomislacker / vpc.ipynb
Created July 10, 2018 16:49
VPC Network Designer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

How to create a publicly-accessible SNS topic that sends messages when objects are added to a public Amazon S3 bucket.

1. Create something within AWS that triggers notifications.

In this case, that's an S3 bucket that is continually updated by the addition of new sensor data. For the purposes of this tutorial, we’ll use s3://noaa-nexrad-level2 – one of our NEXRAD on AWS buckets – as an example.

2. Create an SNS topic and appropriate policy.

The SNS topic should be in the same region as the bucket. It will need to have a policy that allows our S3 bucket to publish to it, and anyone to subscribe to it using Lambda or SQS.

@tomislacker
tomislacker / elasticache_benchmarking.ipynb
Last active May 4, 2018 21:10
Benchmarking ElastiCache (Redis) Bandwidth Performance
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tomislacker
tomislacker / ec2_kill_with_fire.py
Last active November 14, 2018 06:33
Kill EC2 Instances With Fire
#!/usr/bin/env python
"""
EC2 Instance Killer
Usage:
ec2_kill_with_fire.py [options] <instance_id>...
Options:
-h, --help Show this dialog
-r, --region NAME EC2 region [default: us-east-1]
@tomislacker
tomislacker / etag.py
Created January 3, 2018 17:14
S3 Multipart Upload ETag Calculator
#!/usr/bin/env python
"""
USAGE: etag.py {file} [chunk size in bytes]
Calculates the S3 ETag of a multi-part upload
$ ./etag.py Downloads/c2560cf.zip
Downloads/c2560cf.zip 56daa8b3846a358207edc89e9bb90309-6
"""
from __future__ import print_function
@tomislacker
tomislacker / rds_set_all_maint.sh
Created December 12, 2017 15:54
RDS Set All Maintenance Windows
#!/bin/bash
WINDOW=Tue:15:00-Tue:15:30
set_window ()
{
local db_id=$1
aws rds modify-db-instance \
--db-instance-identifier $db_id \
--preferred-maintenance-window $WINDOW
@tomislacker
tomislacker / us_populations.ipynb
Last active December 12, 2017 14:49
Top Cities (& metro areas) Alphabetically
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tomislacker
tomislacker / fix_acl.py
Created December 8, 2017 14:51
Fix S3 ACL for public reads after `s3 sync s3://src s3://dst`
#!/usr/bin/env python
from __future__ import print_function
import boto3
import sys
s3 = boto3.resource('s3')
try:
bucket = s3.Bucket(sys.argv[1])
except IndexError:
@tomislacker
tomislacker / r53_finder.py
Last active September 14, 2017 17:13
Route53 RecordSet Finder
#!/usr/bin/env python
from __future__ import print_function
import boto3
import sys
r53 = boto3.client('route53')