Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

View GitHub Profile
@filipeandre
filipeandre / parse_yaml.sh
Created April 25, 2019 13:36 — forked from pkuczynski/LICENSE
Read YAML file from Bash script
#!/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]}}
@filipeandre
filipeandre / my-emr.yaml
Created June 17, 2019 17:13 — forked from gordonclarkok/my-emr.yaml
My example AWS EMR cluster in cloudformation - security groups in separate file
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
___ _____ ___ _ _ __ _ _ ___ _ _ ___ _ _ _
/_\ \ / / __| ___ / __|___ _ _| |_(_)/ _(_)___ __| | / __| ___ __ _ _ _ _(_) |_ _ _ / __|_ __ ___ __(_)__ _| | |_ _ _
/ _ \ \/\/ /\__ \ |___| | (__/ -_) '_| _| | _| / -_) _` | \__ \/ -_) _| || | '_| | _| || | \__ \ '_ \/ -_) _| / _` | | _| || |
/_/ \_\_/\_/ |___/ \___\___|_| \__|_|_| |_\___\__,_| |___/\___\__|\_,_|_| |_|\__|\_, | |___/ .__/\___\__|_\__,_|_|\__|\_, |
|__/ |_| |__/
Notes taken in Mar-2018, from acloud.guru and AWS FAQ
___ _ _ _ __ _
/ __| ___ __ _ _ _ _(_) |_ _ _ / |/ \/ |
@filipeandre
filipeandre / route53_delete_zone.py
Created December 6, 2019 20:55 — forked from Voronenko/route53_delete_zone.py
Route53 delete zone
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']
@filipeandre
filipeandre / discovery.py
Created December 6, 2019 21:08 — forked from bploetz/discovery.py
Ground Signal Engineering - Service Discovery Example
import json
import boto3 # boto3-1.5.7
import os
import logging
import time
import sys
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@filipeandre
filipeandre / rmvpc.py
Created December 6, 2019 23:04 — forked from alberto-morales/rmvpc.py
Deleting an AWS VPC with python's boto3
#!/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:
@filipeandre
filipeandre / RemoveDefaultVPC.py
Created December 6, 2019 23:13 — forked from restump/RemoveDefaultVPC.py
Remove default VPC
#!/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',
@filipeandre
filipeandre / aws_clean_security_groups.py
Created December 6, 2019 23:13 — forked from chowyi/aws_clean_security_groups.py
python script to clean AWS useless security groups.
# 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'
@filipeandre
filipeandre / lambda-aws-ssm-run-command-on-ec2-instance.py
Created December 7, 2019 18:48 — forked from lrakai/lambda-aws-ssm-run-command-on-ec2-instance.py
Run commands on EC2 instances using Lambda and Systems Manager (SendCommand)
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(
@filipeandre
filipeandre / envoy-external-lb-dynamic.yaml
Created December 18, 2019 14:17 — forked from vbanthia-zz/envoy-external-lb-dynamic.yaml
Simple static envoy config for external kubernetes load balancer
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.tcp_proxy
config: