Skip to content

Instantly share code, notes, and snippets.

@dgulinobw
dgulinobw / getopenPRs.5m.sh
Last active February 8, 2022 16:49
argos/bitbar plugin to check bitbucket PR requests
#!/bin/bash
# shellcheck disable=SC2034
# shellcheck disable=SC2154
# shellcheck source=/dev/null
# <bitbar.title>Bitbucket Pull Requests</bitbar.title>
# <bitbar.version>1.0</bitbar.version>
# <bitbar.author>Mikey Beck</bitbar.author>
# <bitbar.author.github>mikeybeck</bitbar.author.github>
# <bitbar.desc>Shows Bitbucket open pull request information</bitbar.desc>
@dgulinobw
dgulinobw / gerrit_incoming_crs.5m+.py
Last active January 27, 2022 17:35
bitbar/argos gerrit open and unapproved change reviews
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# <bitbar.title>Gerrit Incoming Code Reviews</bitbar.title>
# <bitbar.version>v1.1</bitbar.version>
# <bitbar.author>Ryan Sydnor</bitbar.author>
# <bitbar.author>Drew Gulino</bitbar.author>
# <bitbar.author.github>ryansydnor</bitbar.author.github>
# <bitbar.desc>Displays your incoming code reviews.</bitbar.desc>
# <bitbar.dependencies>python</bitbar.dependencies>
@dgulinobw
dgulinobw / iam_key_scan.py
Created July 22, 2021 18:46
List all users and their active access keys
#!/usr/bin/env python
from __future__ import print_function
import boto3
iam = boto3.resource('iam')
for user in iam.users.all():
for key in user.access_keys.all():
if key.status == "Active":
print("user: {}, key: {}".format(user.name, key.id))
@dgulinobw
dgulinobw / replace_ec2_sg_ip.py
Created July 22, 2021 18:12
Search and replace an IP/CIDR in all AWS EC2 security groups
#!/usr/bin/env python
from __future__ import print_function
import json
import boto3
from botocore.exceptions import ClientError
ip="50.56.24.206/32"
new_ip="192.237.176.126/32"
for region in ["us-east-1","us-west-1", "us-west-2"]:
@dgulinobw
dgulinobw / ec2_sg_scan.py
Created July 22, 2021 18:06
Searches through AWS EC2 security groups for entries. Example: ./ec2_sg_scan.py 1.2.3.4
#!/usr/bin/env python
from __future__ import print_function
import sys
import json
import boto3
from pprint import pprint
from termcolor import colored
from botocore.exceptions import ClientError
@dgulinobw
dgulinobw / iam_scan.py
Last active July 22, 2021 20:57
List out all AWS IAM policies of user, group, role, and s3 buckets
#!/usr/bin/env python
from __future__ import print_function
import boto3
import sys
from pygments import highlight, lexers, formatters
from botocore.exceptions import ClientError
iam = boto3.resource('iam')
s3 = boto3.client('s3')
@dgulinobw
dgulinobw / gerrit_incoming_crs.5m+.py
Created June 10, 2021 16:13
Gerrit Incoming Code Reviews for bitbar/argos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# <bitbar.title>Gerrit Incoming Code Reviews</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Ryan Sydnor</bitbar.author>
# <bitbar.author.github>ryansydnor</bitbar.author.github>
# <bitbar.desc>Displays your incoming code reviews.</bitbar.desc>
# <bitbar.dependencies>python</bitbar.dependencies>
@dgulinobw
dgulinobw / aws_savings_plan_report.py
Created December 8, 2020 23:10
Split EC2 savings plan savings between product tags
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import csv
from functools import reduce
from operator import add
import boto3
ce = boto3.client('ce')
@dgulinobw
dgulinobw / nginx_accesslog2csv.py
Last active February 14, 2023 10:15
Convert Nginx combinded access log to CSV format, splitting path and parameters into columns, in a memory-efficient manner.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# nginx_accesslog2csv: Convert nginx default, combined access log to CSV format
import os
import csv
import re
import sys
import datetime
@dgulinobw
dgulinobw / ddbBackup.py
Created January 17, 2020 15:23
AWS Lambda + standalone script to backup all DynamoDB tables.
#!/usr/bin/env python
#based on:
#https://aws.amazon.com/blogs/database/a-serverless-solution-to-schedule-your-amazon-dynamodb-on-demand-backup/
from __future__ import print_function
from datetime import date, datetime, timedelta
import json
import boto3
import time
from botocore.exceptions import ClientError
import os