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/sh | |
| parse_yaml() { | |
| local prefix=$2 | |
| local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') | |
| sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ | |
| -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | | |
| awk -F$fs '{ | |
| indent = length($1)/2; | |
| vname[indent] = $2; | |
| for (i in vname) {if (i > indent) {delete vname[i]}} |
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
| AWSTemplateFormatVersion: 2010-09-09 | |
| Description: EMR Cluster with Hadoop, Hbase, Spark, Ganglia and Zookeeper | |
| Parameters: | |
| EMRClusterName: | |
| Description: Name of the cluster | |
| Type: String | |
| Default: emrcluster | |
| KeyName: | |
| Description: Must be an existing Keyname | |
| Type: String |
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
| ___ _____ ___ _ _ __ _ _ ___ _ _ ___ _ _ _ | |
| /_\ \ / / __| ___ / __|___ _ _| |_(_)/ _(_)___ __| | / __| ___ __ _ _ _ _(_) |_ _ _ / __|_ __ ___ __(_)__ _| | |_ _ _ | |
| / _ \ \/\/ /\__ \ |___| | (__/ -_) '_| _| | _| / -_) _` | \__ \/ -_) _| || | '_| | _| || | \__ \ '_ \/ -_) _| / _` | | _| || | | |
| /_/ \_\_/\_/ |___/ \___\___|_| \__|_|_| |_\___\__,_| |___/\___\__|\_,_|_| |_|\__|\_, | |___/ .__/\___\__|_\__,_|_|\__|\_, | | |
| |__/ |_| |__/ | |
| Notes taken in Mar-2018, from acloud.guru and AWS FAQ | |
| ___ _ _ _ __ _ | |
| / __| ___ __ _ _ _ _(_) |_ _ _ / |/ \/ | |
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
| def delete_zone(domain): | |
| """ Deleting a hosted zone in AWS is a real pain if you have any number of | |
| resource records defined because you must first delete all RR's in order to | |
| remove the zone. This is a one-stop script to do all of that in one command. | |
| """ | |
| import boto | |
| from boto.route53.record import ResourceRecordSets | |
| PROTECTED_DOMAINS = ['foo.com', 'bar.net'] | |
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 json | |
| import boto3 # boto3-1.5.7 | |
| import os | |
| import logging | |
| import time | |
| import sys | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.INFO) |
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
| #!/usr/bin/env python | |
| import boto3, argparse, sys, time | |
| parser = argparse.ArgumentParser(description="Remove default VPC in specified account and region") | |
| parser.add_argument('--account', | |
| type=str ) | |
| parser.add_argument('--region', | |
| type=str ) | |
| parser.add_argument('--role', |
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
| # coding:utf-8 | |
| import boto3 | |
| import logging | |
| logging.basicConfig( | |
| format='%(levelname)s %(asctime)s\n%(message)s', | |
| datefmt='%Y-%m-%d %H:%M:%S', | |
| filename='./clean_security_groups.log', | |
| level=logging.INFO, | |
| filemode='a' |
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 botocore | |
| import time | |
| def handler(event=None, context=None): | |
| client = boto3.client('ssm') | |
| instance_id = 'i-07362a00952fca213' # hard-code for example | |
| response = client.send_command( |
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
| static_resources: | |
| listeners: | |
| - address: | |
| socket_address: | |
| address: 0.0.0.0 | |
| port_value: 80 | |
| filter_chains: | |
| - filters: | |
| - name: envoy.tcp_proxy | |
| config: |