Skip to content

Instantly share code, notes, and snippets.

@pilgrim2go
pilgrim2go / add-dns-record.sh
Created February 23, 2017 07:04 — forked from justinclayton/add-dns-record.sh
CLI to add DNS Records in Route53
#!/bin/bash -eo pipefail
## Allows for creation of "Basic" DNS records in a Route53 hosted zone
function main() {
record_name=$1
record_value=$2
[[ -z $record_name ]] && echo "record_name is: $record_name" && exit 1
[[ -z $record_value ]] && echo "record_value is: $record_value" && exit 1
@pilgrim2go
pilgrim2go / pvsdisplay-friendly.sh
Last active March 9, 2017 02:37
How to display used devices/free space when using LVM?
# http://unix.stackexchange.com/questions/103535/how-can-i-find-out-the-free-space-on-an-lvm-pv-in-human-readable-format
pvdisplay | perl -plne '$f=$1 if /Free PE\s*(\d+)/;
$s=$1 if /PE Size.*?(\d+)/;
print " Free Space\t\t",($s*$f)/1048576," GiB" if /UUID/'
--- Physical volume ---
PV Name /dev/sda2
VG Name MMB
PV Size 29.71 GB / not usable 19.77 MB
@pilgrim2go
pilgrim2go / infra-secret-management-overview.md
Created March 13, 2017 06:52 — forked from maxvt/infra-secret-management-overview.md
Infrastructure Secret Management Software Overview

Currently, there is an explosion of tools that aim to manage secrets for automated, cloud native infrastructure management. Daniel Somerfield did some work classifying the various approaches, but (as far as I know) no one has made a recent effort to summarize the various tools.

This is an attempt to give a quick overview of what can be found out there. The list is alphabetical. There will be tools that are missing, and some of the facts might be wrong--I welcome your corrections. For the purpose, I can be reached via @maxvt on Twitter, or just leave me a comment here.

There is a companion feature matrix of various tools. Comments are welcome in the same manner.

@pilgrim2go
pilgrim2go / s3bucketsize.py
Created March 15, 2017 02:32 — forked from robinkraft/s3bucketsize.py
Simple python script to calculate size of S3 buckets
import boto
s3 = boto.connect_s3(aws_id, aws_secret_key)
# based on http://www.quora.com/Amazon-S3/What-is-the-fastest-way-to-measure-the-total-size-of-an-S3-bucket
def get_bucket_size(bucket_name):
bucket = s3.lookup(bucket_name)
total_bytes = 0
n = 0
for key in bucket:
@pilgrim2go
pilgrim2go / sns-sample.py
Created March 23, 2017 04:35
Sample test to verify SNS permission
import boto3
client = boto3.client('sns',
region_name='us-west-2',
aws_access_key_id='aws_access_key_id',
aws_secret_access_key='aws_secret_access_key'
)
response = client.publish(
TopicArn='full_arn_topic_name',
@pilgrim2go
pilgrim2go / dynamodb-update-reserved.py
Created March 23, 2017 04:44
Using ExpressionAttributeNames to alias DynamoDB reserved keywords
from __future__ import print_function
import boto3
import json
import decimal
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError
from pprint import pprint
@pilgrim2go
pilgrim2go / haproxy.cfg
Created April 3, 2017 07:57 — forked from uorat/haproxy.cfg
HAProxy configuration sample with resolvers options
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4096
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
@pilgrim2go
pilgrim2go / get_s3_file.sh
Created April 12, 2017 02:28 — forked from davidejones/get_s3_file.sh
curl get file from private s3 with iam role
#!/bin/bash
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
token=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | sed -n '/Token/{p;}' | cut -f4 -d'"'`
file="somefile.deb"
bucket="some-bucket-of-mine"
date="`date +'%a, %d %b %Y %H:%M:%S %z'`"
@pilgrim2go
pilgrim2go / df-sort.sh
Created April 25, 2017 04:47
Sort disk usage using df command
From: https://lists.gnu.org/archive/html/bug-coreutils/2007-01/msg00131.html
```
df -Pk | tail -n +2 | sort -k3,3n
```
Or if you want to preserve the header, use a script like this:
@pilgrim2go
pilgrim2go / logback.xml
Created May 15, 2017 07:17 — forked from jcraane/logback.xml
Sample logback.xml file with console and rolling file appender. The rollover is time based (daily) and size based, 5MB.
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">