Skip to content

Instantly share code, notes, and snippets.

@jayers99
jayers99 / secureCRTconfig.ini
Last active March 28, 2019 23:07
config changes to securityCRT
securecrt changes
win location
C:\Users\userid\AppData\Roaming\VanDyke\Config
SSH2.ini
D:"Enable Agent Forwarding"=00000001
Color Schemes.ini
@jayers99
jayers99 / tfgrep_dirs.sh
Last active March 27, 2019 19:49
get all the directory names that contain some string
#!/bin/bash
# return a list of directories the contain given text
# example: ~/scripts/tfgrep_dirs.sh '^\s*source\s*=\s*.*some_module_name'
file_paths=$(grep -irlP --include \*.tf --exclude-dir=.terraform --exclude-dir=.git $@)
dirs_array=()
for i in $file_paths; do
dirs_array+=($(dirname $i))
done
@jayers99
jayers99 / sqsFun.sh
Created March 26, 2019 17:01
Fun with AWS SQS message queues
#s3 put notification
aws sqs receive-message --queue-url https://sqs.us-west-2.amazonaws.com/someaccount/somequeue --visibility-timeout 1 --max-number-of-messages 10 | jq -r '.Messages[].Body' | jq -r '.Message' | jq '.Records[].s3.object.key'
#!/bin/bash
logpath=${HOME}/logs
random=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 8)
logname=flowlog
mv ${logpath}/${logname} ${logpath}/archive/${logname}_${random}
mv ${logpath}/${logname}_sort ${logpath}/archive/${logname}_${random}_sort
mv ${logpath}/${logname}_top ${logpath}/archive/${logname}_${random}_top
mv ${logpath}/${logname}_reject ${logpath}/archive/${logname}_${random}_reject
mv ${logpath}/${logname}_rejectTop ${logpath}/archive/${logname}_${random}_rejectTop
@jayers99
jayers99 / resolveInterface.sh
Last active April 1, 2019 18:46
resolve some sort of name for an aws interface id
#!/bin/bash
# todo - add a cache so it will not have to query repeat eni ids
instanceId=""
instanceName=""
interfaceInfo=""
exitcode=""
declare -A cache=()
interfaceId=$1
{
cmd = ". ./resolveInterface.sh "$2
cmd | getline srcDesc
close(cmd)
printf "%5d %-16s %-16s %5d %s\n",$1, $3, $4, $5, srcDesc
}
{
printf "%-21s %-16s %-16s %-5s %s\n", $3, $4, $5, $7, $13
}
@jayers99
jayers99 / flowlog.awk
Created March 25, 2019 17:15
pretty print aws vpc flow logs
{
cmd = "date -d @"$11" +%Y-%m-%dT%H:%M:%S"
cmd | getline myTime
close(cmd)
printf "%s %-16s %-5s %-16s %-5s %s\n", myTime, $4, $6, $5, $7, $13
}
@jayers99
jayers99 / policy_diff_tfplan.sh
Last active March 29, 2019 01:13
terraform plan policy differences
# final final
string=$(cat sample.txt | grep -P '^\s+policy:' | sed -r 's/\s*policy:\s*//g; s/\\n//g; s/\\\"/"/g; s/\s+//g; s/=>/\n/g')
IFS=$'\n' GLOBIGNORE='*' command eval 'array=($string)'
diff <(echo ${array[0]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') <(echo ${array[1]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') | grep -v "^[0-9c0-9]"
# sed file
s/\s*policy:\s*//g
s/\\n//g
s/\\\"/"/g
@jayers99
jayers99 / tfsearchFun.sh
Created March 21, 2019 19:14
search terraform returning entire resource block
# might be a good starting point
https://stackoverflow.com/questions/6133989/what-grep-command-will-include-the-current-function-name-in-its-output