Skip to content

Instantly share code, notes, and snippets.

View smstec's full-sized avatar

Matt Stec smstec

View GitHub Profile
@smstec
smstec / asg_worker.py
Last active May 10, 2019 13:22
AWS Auto Scaling Group Clean Shutdown
import datetime
from time import sleep
import boto3
import requests
SPOT_URL = 'http://169.254.169.254/latest/meta-data/spot/instance-action'
ID_URL = 'http://169.254.169.254/latest/meta-data/instance-id'
EC2 = boto3.client('ec2')
@smstec
smstec / iptables-pihold-bypass.sh
Created December 12, 2018 18:19
Bypass pihole for certain IP addresses.
#!/bin/bash
# -- Assumptions/Warnings:
# -- You're not using any kind of NAT or custom iptables rules already on the Pi (as these will be wiped)
# -- <PUT_IP_ADDRESS_HERE> is the device you wish to exclude
# -- 1.1.1.1 is the DNS server you wish excluded devices to use (this is the cloudflare server)
# -- stolen from https://www.reddit.com/r/pihole/comments/56y6lb/ignore_one_device_completely/d8niqzi
# Run as root/sudo it.
sysctl net.ipv4.ip_forward=1
@smstec
smstec / create_security_group.py
Last active November 12, 2018 14:35
Creates EC2 security group across region/VPCs to access SSH.
from __future__ import division, print_function
import click
import boto3
import os
import socket
from botocore.exceptions import ClientError
def create_security_groups(region, ipv4, vpcid, group_name):
new_group = False