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/bash | |
export AWS_PROFILE=default | |
FULLPATH="s3://jayers99-flowlog-test/AWSLogs/441655563487/vpcflowlogs/" | |
BUCKET=$(echo "$FULLPATH" | cut -d "/" -f3) | |
echo "#$BUCKET#"; | |
echo ; | |
LASTFILES=$(aws s3 ls $FULLPATH --recursive | sort | tail -n 10 | awk '{print $4}') |
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
aws cloudtrail lookup-events --profile dev --max-results 10 \ | |
--lookup-attributes AttributeKey=EventName,AttributeValue=GetTrailStatus --query 'Events[*].CloudTrailEvent' | jq -r . | jq . | |
# events by some user | |
aws cloudtrail lookup-events --profile dev --max-results 50 \ | |
--lookup-attributes AttributeKey=Username,AttributeValue=someUserName --query 'Events[*].CloudTrailEvent' | jq -r . | jq .eventName | |
# write events | |
aws cloudtrail lookup-events --profile dev --max-results 100 \ | |
--lookup-attributes AttributeKey=ReadOnly,AttributeValue=false --query 'Events[*].CloudTrailEvent' | jq -r . |
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/bash | |
export AWS_PROFILE=dev | |
FULLPATH="s3://somebucket/logs/AWSLogs/1234567890/elasticloadbalancing/us-west-2/2019/03/" | |
BUCKET=$(echo "$FULLPATH" | cut -d "/" -f3) | |
echo "#$BUCKET#"; | |
echo ; | |
LASTFILES=$(aws s3 ls $FULLPATH --recursive | sort | tail -n 10 | awk '{print $4}') |
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/bash | |
# get the root repo directory | |
repo_dir=$(git rev-parse --show-toplevel) | |
# creast a list of directories to run the plan against | |
dirs=$(ls -d $repo_dir/network/vpc*) | |
# set the report file name | |
mkdir -p $HOME/reports/ |
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 bash | |
planfile=$HOME/plans/${PWD##*/}_$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 8) | |
planfilepr=$planfile'PR.md' | |
repodir=$(git rev-parse --show-prefix) | |
# set the proxy if not | |
if [[ -z "${http_proxy}" ]]; then setproxy; fi | |
if [[ ! -d .terraform ]]; then terraform init; fi |
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
cat statefile.tfstate | jq '.. | objects | with_entries(select(.key | contains("aws_network_acl_rule"))) | select(. != {})' | |
# all the acl objects | |
jq '.modules[].resources[].primary | select(.id | startswith("acl-"))' statefile.tfstate |
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
grep -ir --no-filename --include \*.tf --exclude-dir=.terraform --exclude-dir=.git -P 'name\s+=\s+\"\$\{var\.\w+\}[\w\-]*\-policy"' | sed 's/\s*name\s*=\s*//' | sort | uniq -d |
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
# Is this network contained in this other network | |
import ipaddress | |
rule = ipaddress.IPv4Network('10.19.252.0/24') | |
net = ipaddress.IPv4Network('10.19.252.16/29') | |
rule.overlaps(net) | |
net = ipaddress.IPv4Network('10.19.253.16/29') | |
rule.overlaps(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
grep -Proh --include \*.tf --exclude-dir=.terraform --exclude-dir=.git '\$\{var\.[\w]+\}' | sort | uniq -c | sort -nr | |
find ~/tf/ -name *.tf -exec grep -Proh '\$\{var.[\w]+\}' {} \; | sort | uniq -c | sort -nr > ~/temp/varlist |
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
find /home/jayers -exec ls -ald {} \; | awk '{ print $4," ",$NF }' | awk -F \/ '{ print $1,"/",$4,"/",$5,"/",$NF}' | grep -v jayers |