Skip to content

Instantly share code, notes, and snippets.

@rdkls
rdkls / alb logs athena setup
Last active July 11, 2023 13:20
athena table create statement for one bucket holding multiple load balancer access logs (default example is limited to one table per alb)
Note the projection for api/alb name is an enum not 'injected' to enable querying on it
CREATE EXTERNAL TABLE IF NOT EXISTS alb_logs (
type string,
time string,
elb string,
client_ip string,
client_port int,
target_ip string,
target_port int,
@rdkls
rdkls / gist:346f681fed749c7f6ba832447ccdb3d7
Last active September 27, 2022 07:11
fish script to run a command on all pods
for pod in (kubectl get pods --field-selector=status.phase=Running --no-headers -o custom-columns=":metadata.name")
echo $pod
kubectl exec -ti $pod -- ping 1.1.1.1 -W1 -c1 -q >/dev/null
end
@rdkls
rdkls / gcp-aws-vpn.create.py
Created August 9, 2022 23:56
gcp-aws-vpn.create.py
#!/usr/bin/env python3
# Stand up a VPN between GCP & AWS
# Assumes you're CLI auth'd to both as default
# Based on https://cloud.google.com/architecture/build-ha-vpn-connections-google-cloud-aws
# Yes it's ugly AF but basically working!
# Usage: ./setup-vpn.py --shared-secret-0=xxxxxx --shared-secret-1=aaaaa --shared-secret-2=bbbb --shared-secret-3=cccc
# You'll need to to pip[env] install beautifulsoup4 click boto3 lxml
import subprocess
import json
@rdkls
rdkls / .pre-commit-config.yaml
Created September 9, 2021 01:59
pre-commit config to run checkov
repos:
- repo: https://github.com/bridgecrewio/checkov.git
rev: 2.0.402
hooks:
- id: checkov
files: .
args:
- --quiet
@rdkls
rdkls / ec2-instance-prep-for-tf-dev.sh
Created July 23, 2021 05:03
commands to prep an ec2 instance for terraform dev, by mounting local folder via sshfs
set -x
sudo amazon-linux-extras enable epel
sudo yum install epel-release fuse-sshfs
sudo sed -i s/\#\ user/user/g /etc/fuse.conf
sudo curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash
sudo wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.31.1/terragrunt_linux_amd64 -O /usr/bin/terragrunt
sudo chmod +x /usr/bin/terragrunt
sudo wget https://github.com/Versent/saml2aws/releases/download/v2.31.0/saml2aws_2.31.0_linux_amd64.tar.gz -O /usr/bin/saml2aws_2.31.0_linux_amd64.tar.gz
sudo tar -xzvf /usr/bin/saml2aws_2.31.0_linux_amd64.tar.gz
sudo chmod +x /usr/bin/saml2aws
#!/usr/bin/env python3
from github import Github
from pprint import pprint
import requests
TOKEN = 'PERSONAL_ACCESS_TOKEN'
g = Github(TOKEN)
for repo in g.get_user().get_repos(visibility='public'):
sha256 of all running executables
for f in `ps -eo comm` ; do shasum5.28 -a 256 "$f" ; done
openssl genrsa -out key.pem
openssl rsa -in key.pem -pubout -out key.pub
Now you'll have pub + private keys
You can send the pub key to supplying user, who can then encrypt with it, and you can decrypt
To encrypt:
echo "xxxxxxxx" | openssl rsautl -encrypt -inkey ./key.pub -pubin | base64
// ==UserScript==
// @name Whitelist AWS Console Service list
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Show only selected services in the AWS Web Console Services menu
// @author rdkls
// @match https://*console.aws.amazon.com/*
// @match https://*.console.aws.amazon.com/*
// @grant none
// ==/UserScript==
#!/usr/bin/env python3
import argparse
import boto3
import botocore
import sys
import csv
from itertools import repeat as r
import concurrent.futures