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 secrets | |
import boto3 | |
import cfnresponse | |
ec2 = boto3.resource('ec2') | |
def create_ami(instance_id, ami_name, description): | |
instance = ec2.Instance(instance_id) |
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 -xe | |
# This script requires `jq` and optionally `awsume` | |
awsume --session-name ssummers-update-api-keys # or whatever method to assume an mfa session | |
AWS_EXPIRING_ACCESS_KEY=$(aws configure get aws_access_key_id) | |
AWS_USER=$(aws sts get-caller-identity --query Arn --output text | awk -F/ '/:user/ {print $2}') | |
if [[ $(aws iam list-access-keys --user-name ${AWS_USER} --query '*[]|length(@)') -ne 1 ]] | |
then |
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
# ---------------------- | |
# Git Aliases, mostly from https://jonsuh.com/blog/git-command-line-shortcuts/ | |
# ---------------------- | |
alias ga='git add' | |
alias gaa='git add .' | |
alias gaaa='git add --all' | |
alias gau='git add --update' | |
alias gb='git branch' | |
alias gbd='git branch --delete ' | |
alias gc='git commit' |
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 itertools import tee | |
try: | |
from itertools import zip_longest | |
except ImportError: | |
from itertools import izip_longest as zip_longest | |
def snake_parts_from_camel(name): | |
parts = tee(name, 2) | |
next(parts[1]) |
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
--- | |
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Global assets needed for Inventory Discovery | |
Metadata: | |
AWS::CloudFormation::Interface: |
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 boto3 | |
import json | |
client = boto3.client('iam') | |
paginator = client.get_paginator('list_policies') | |
response_iterator = paginator.paginate(Scope='AWS') | |
managed_policies = [] | |
for response in response_iterator: | |
for policy in response['Policies']: |
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
"""Attempt to remove a VPC by removing the minimum resources required first. | |
Defaults to removing all default vpcs in all regions. | |
""" | |
import logging | |
import boto3 | |
logging.basicConfig(level = logging.INFO) |
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
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Template to create libnd EC2 | |
Conditions: | |
HasNetworkInterfaceId: !Not [!Equals [!Ref NetworkInterfaceId, '']] | |
HasPrivateIpAddress: !Not [!Equals [!Ref PrivateIpAddress, '']] | |
Parameters: | |
AMI: | |
ConstraintDescription: must be an AMI available in the EC2 instance's region | |
Default: ami-6869aa05 | |
Description: Base AMI |
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
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Create a Volume from scratch and attach it to an instance. | |
Metadata: | |
AWS::CloudFormation::Interface: |
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
{ | |
"universityarchives": "5561", | |
"reservesmicrotextandmediadesk": "5557", | |
"medievalinstitutelibrary": "5558", | |
"circulationservicedesk": "1483", | |
"engineeringlibrary": "5566", | |
"architecturelibrary": "5563", | |
"kelloggkroclibrary": "5567", | |
"mahaffeybusinesslibrary": "5564", | |
"chemistryphysicslibrary": "5565", |