Skip to content

Instantly share code, notes, and snippets.

View reschenburgIDBS's full-sized avatar

Roland Eschenburg reschenburgIDBS

View GitHub Profile
@reschenburgIDBS
reschenburgIDBS / .bashrc
Last active April 12, 2021 15:53
kubeconfig management
# kubeconfig management
function kubeconfig() {
local kubeconfigDir="$HOME/.kube/configs"
unset KUBECONFIG
for config in $(ls -d ${kubeconfigDir}/*); do
export KUBECONFIG=$KUBECONFIG:$config
done
}
kubeconfig
@reschenburgIDBS
reschenburgIDBS / .bashrc
Last active January 20, 2022 15:30
quick aws assume-role based on configured profiles - requires https://github.com/junegunn/fzf and https://stedolan.github.io/jq/
function awsaroff {
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
aws sts get-caller-identity
}
function awsar {
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
local ARN="$(cat ~/.aws/config | grep "arn:aws" | awk -F " = " '{print $2};' | fzf)"
echo "assuming role: ${ARN}"
if [[ ! $1 ]]; then
@reschenburgIDBS
reschenburgIDBS / .bashrc
Last active October 2, 2020 12:44
version switcher for kubectl, kops, helm and terraform - requires https://github.com/junegunn/fzf
function versionswitcher {
local BINARY="$1"
local URL="$2" #must contain 'VERSION' in it somewhere to enable download of different versions
local CACHE="${HOME}/.${BINARY}.versions"
local DSTFILE="/usr/local/bin/${BINARY}"
local TEMPDIR="${CACHE}/tmp"
mkdir -p "$CACHE"
if [[ ! "$3" ]]; then
@reschenburgIDBS
reschenburgIDBS / main.tf
Last active October 30, 2020 11:46
terraform Global Accelerator Security Group in VPC workaround with assume role support - requires jq installed on the terraforming device!!
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "test-vpc"
}
provisioner "local-exec" {
when = destroy
command = <<EOT
@reschenburgIDBS
reschenburgIDBS / main.tf
Created October 23, 2020 11:19
terraform Global Accelerator Security Group in VPC workaround
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "test-vpc"
}
provisioner "local-exec" {
when = destroy
command = <<EOT
@reschenburgIDBS
reschenburgIDBS / fix-tiller-image.sh
Created September 3, 2021 08:28
patch tiller image to new ghcr registry
#!/usr/bin/env bash
# stashing original context
OLD_CONTEXT=$(kubectl config current-context)
if [ -z "$1" ]; then
NEW_CONTEXT=$(kubectl config get-contexts --output=name | fzf)
else
NEW_CONTEXT="$1"
fi
@reschenburgIDBS
reschenburgIDBS / .bashrc
Last active January 25, 2022 14:58
git lazy - aliases/functions for simple repeating git tasks
# git lazy - add all files, commit all files and publish all changes
function gl {
echo "${BOLD}${MAGENTA}[ Git Lazy ]${END}"
PRETTYBRANCH=$(script -q /dev/null git status -sb | head -1)
echo "${BLUE}On branch${END} $PRETTYBRANCH"
echo "${YELLOW}+ Pull${END}"
git pull
echo "${YELLOW}+ Adding files${END}"
git status -s
git add --all
@reschenburgIDBS
reschenburgIDBS / .bash_profile
Created January 25, 2022 15:01
colours in bash etc
# enable colours
RED=$'\e[1;31m'
GREEN=$'\e[1;32m'
YELLOW=$'\e[1;33m'
BLUE=$'\e[1;34m'
MAGENTA=$'\e[1;35m'
CYAN=$'\e[1;36m'
END=$'\e[0m'
# enable special text formating