This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo | |
echo usage: $0 network-interface | |
echo | |
echo e.g. $0 eth0 | |
echo | |
echo shows packets-per-second |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import boto3 | |
import csv | |
from botocore.exceptions import ClientError | |
ec2 = boto3.client('ec2') | |
def get_snapshots(): | |
return ec2.describe_snapshots(OwnerIds=['self'])['Snapshots'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import json | |
import boto3 | |
import logging | |
#setup simple logging for INFO | |
logger = logging.getLogger() | |
logger.setLevel(logging.ERROR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# lists all unused AWS security groups. | |
# a group is considered unused if it's not attached to any network interface. | |
# requires aws-cli and jq. | |
# all groups | |
aws ec2 describe-security-groups \ | |
| jq --raw-output '.SecurityGroups[] | [.GroupName, .GroupId] | @tsv' \ | |
| sort > /tmp/sg.all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Code adapted from and inspired by http://blog.ranman.org/cleaning-up-aws-with-boto3/. | |
""" | |
import os | |
import re | |
from datetime import datetime, timedelta | |
import boto3 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
import logging | |
import os | |
import boto3 | |
logging.basicConfig(level=os.environ.get('LOG_LEVEL', 'INFO')) | |
ec2 = boto3.client('ec2') | |
logger = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
REPO_DIR=~/.iam_lookup/complete-aws-iam-reference | |
REPO_URL=https://github.com/widdix/complete-aws-iam-reference | |
if [[ $1 == "update" ]];then | |
if [[ -e $REPO_DIR ]];then | |
(cd "$REPO_DIR" && git pull) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run as sudo. for weekly backup of db. and upload to s3 bucket. | |
DBHOME="/home/priyank/crontabs/dbbackups/" | |
BUCKETNAME="yourAWSbucket" | |
SCRIPTNAME="$(basename $BASH_SOURCE)" | |
SCRIPTFULLPATH="$(pwd)/$(basename $BASH_SOURCE)" | |
mkdir -p $DBHOME | |
chown -R postgres:postgres $DBHOME | |
cp $SCRIPTFULLPATH $DBHOME | |
SCHEMA_BACKUP="$DBHOME/$(date +%w).sql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import time | |
import argparse | |
import boto3 | |
if os.environ.get('AWS_PROFILE') is None: | |
sys.exit('Environment variable AWS_PROFILE not set') | |
argparser = argparse.ArgumentParser(description='Snapshot EC2 instance volume with volume ID specified by argument') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import time | |
import argparse | |
import boto3 | |
if os.environ.get('AWS_PROFILE') is None: | |
sys.exit('Environment variable AWS_PROFILE not set') | |
argparser = argparse.ArgumentParser(description='Snapshot EC2 instance volume with volume ID specified by argument') |
OlderNewer