This file contains hidden or 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 csv | |
import boto3 | |
rest_apis = [] | |
ec2 = boto3.client('ec2', region_name='us-east-1') | |
for region in ec2.describe_regions()['Regions']: | |
print(f"Checking region {region['RegionName']}") | |
session = boto3.Session(region_name=region['RegionName']) | |
apigw = session.client('apigateway') | |
for api in apigw.get_rest_apis()['items']: |
This file contains hidden or 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 csv | |
import boto3 | |
ec2 = boto3.client('ec2', region_name='us-west-1') | |
ssm = boto3.client('ssm', region_name='us-west-1') | |
response = ec2.describe_instances( | |
Filters=[ | |
{'Name':'tag:workload','Values':['somethin']}, | |
{'Name':'tag:environment','Values':['prod']} |
This file contains hidden or 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
{ | |
"eventTypes": [ | |
{ | |
"service": "A4B", | |
"code": "AWS_A4B_API_ISSUE", | |
"category": "issue" | |
}, | |
{ | |
"service": "A4B", | |
"code": "AWS_A4B_CALENDAR_CONNECTIVITY_FAILURE", |
This file contains hidden or 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
[user] | |
email = [email protected] | |
name = Jeremy A | |
[push] | |
default = current | |
[credential] | |
helper = /mnt/c/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe |
This file contains hidden or 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
# system python interpreter. used only to create virtual environment | |
PY = python3 | |
VENV = venv | |
BIN=$(VENV)/bin | |
# make it work on windows too | |
ifeq ($(OS), Windows_NT) | |
BIN=$(VENV)/Scripts | |
PY=python | |
endif |
This file contains hidden or 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 requests.adapters import HTTPAdapter | |
from requests.packages.urllib3.util.retry import Retry | |
def get_requests_retry_session(): | |
retries = Retry(total=5, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504]) | |
adapter = HTTPAdapter(max_retries=retries) | |
http = requests.Session() | |
http.mount("https://", adapter) | |
http.mount("http://", adapter) |
This file contains hidden or 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 python | |
"""I was trying to programatically remove a Virtual Private Cloud (VPC) in | |
AWS and the error message was not helpful: | |
botocore.exceptions.ClientError: An error occurred (DependencyViolation) | |
when calling the DeleteVpc operation: The vpc 'vpc-c12029b9' has | |
dependencies and cannot be deleted. | |
Searching for a quick solution was not fruitful but I was able to glean some | |
knowledge from Neil Swinton's gist: |
This file contains hidden or 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 | |
for file in $(git ls-files); do | |
commits=`git blame $file | cut -f1 -d' ' | sort -u` | |
count=`git blame $file | cut -f1 -d' ' | sort -u | wc -l` | |
comments="" | |
for commit in $commits; do | |
newcommit=`echo $commit | sed -e 's/^\^//g'` |
This file contains hidden or 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 | |
file=$1 | |
commits=`git blame $file | cut -f1 -d' ' | sort -u` | |
count=`git blame $file | cut -f1 -d' ' | sort -u | wc -l` | |
for commit in $commits; do | |
newcommit=`echo $commit | sed -e 's/^\^//g'` | |
user=`git show -s --format='%an' $newcommit` |
This file contains hidden or 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 boto3 | |
import time | |
region = 'eu-west-1' | |
user_data_script = """#!/bin/bash | |
instanceid=$(curl http://169.254.169.254/latest/meta-data/instance-id) | |
cd / | |
mkdir moodledata | |
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-xxxxxxxxxxc.efs.eu-west-1.amazonaws.com:/ moodledata | |
tar czf mooodledata-backup-$(date +%d-%m-%Y_%H-%M).tar.gz /moodledata | |
aws s3 mv mooodledata-backup-*.tar.gz s3://xxxxxxxxx/ |
NewerOlder