Skip to content

Instantly share code, notes, and snippets.

@chattr
chattr / ssh_port_forward_via_ssm.sh
Last active April 15, 2025 11:22
ssh_port_forward_via_ssm.sh
#!/usr/bin/env bash
#
# SSH port forward to EC2 instance via SSM
#
# Dependencies
#
# - Bash >=4
# - AWS Credentials
# - Valid SSH private key for the target EC2 instance
# - [aws-cli](https://aws.amazon.com/cli/)
@chattr
chattr / .bash_functions
Created April 25, 2024 10:54
Useful shell functions
# VSCode diff with ephemeral working directory and files
diffy() (
# shellcheck disable=SC2317
cleanup() {
rm -rf "${HOME}/sandbox"
}
trap cleanup EXIT
trap cleanup TERM
[ ! -d "${HOME}/sandbox" ] && mkdir "${HOME}/sandbox"
@chattr
chattr / auto_configure_aws_cli_sso_roles.sh
Last active April 25, 2025 17:16
Auto-configure AWS CLI ~/.aws/config with SSO roles
#!/usr/bin/env bash
#
# Auto-configure AWS CLI ~/.aws/config with SSO roles
#
#
set -o nounset -o pipefail
# defaults if unset or null
: "${default_region:=eu-west-1}"