Skip to content

Instantly share code, notes, and snippets.

@gianluca-mascolo
gianluca-mascolo / aws-parse.sh
Created September 26, 2023 20:04
split aws config in different profile file
#!/bin/bash
export TMPDIR=/tmp
TMPAWSDIR=$(mktemp -d -t aws.XXXXXX)
pushd "$TMPAWSDIR" > /dev/null 2>&1 || exit
# remove comments from file # split file in multiple ones separated by regex
[ -f ~/.aws/config ] && grep -vE "^([[:blank:]]*#+.*$|$)" ~/.aws/config | csplit -s -z -f aws_profile_ -b %03d - '/^\[profile/' '{*}'
if [ -f aws_profile_000 ]; then
@gianluca-mascolo
gianluca-mascolo / y2j.sh
Created April 6, 2023 22:07
Python oneliner to convert YAML to JSON
cat yamlfile.yml | python -c 'import sys,json,yaml; print(json.dumps(yaml.safe_load(sys.stdin.read()),indent=2))'
# convert a yaml file to json
@gianluca-mascolo
gianluca-mascolo / vault-token-file.sh
Created June 11, 2021 15:04
Vault Token Helper: env variable VAULT_TOKEN_FILE set token location
#!/usr/bin/env bash
# Save this script on your computer, and give it exec permissions (chmod +x)
# To enable it:
# Edit or create ~/.vault Add setting:
# token_helper = "/full/path/to/script/vault-token-file.sh"
# Please refer to: https://www.vaultproject.io/docs/commands/token-helper for further details
@gianluca-mascolo
gianluca-mascolo / bash_profile_switcher.sh
Last active May 8, 2022 17:38
bash profile switcher
# This gist has been deprecated. Have a look to: https://github.com/gianluca-mascolo/bash-profile-switcher