Skip to content

Instantly share code, notes, and snippets.

@PGBI
PGBI / start_ssm_session.sh
Last active March 1, 2023 21:03
Helper to start an SSM session in an ec2 instance knowing its name
# Starts an SSM session in an EC2 instance
#
# Prerequesites: have the following tools installed:
# - awscli
# - jq
# - session-manager-plugin (https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html)
#
# Usage: start_ssm_session <instance ID | IP | Name>
# Examples:
# start_ssm_session i-0041d4a4bd0fdcb2d
@PGBI
PGBI / delete-available-network-interfaces.sh
Created August 18, 2020 16:40
[AWS CLI] Delete all network interfaces in "available" status
aws ec2 describe-network-interfaces \
--filters Name=status,Values=available \
--query "NetworkInterfaces[*].NetworkInterfaceId" \
| jq --raw-output '.[]' | xargs -I {} aws ec2 delete-network-interface --network-interface-id {}
@PGBI
PGBI / .profile
Last active November 25, 2020 20:43
`vagrant halt all` command to halt all running vagrant VMs
# To be pasted in ~/.profile
vagrant() {
if [[ $@ == "halt all" ]]; then
command vagrant global-status | grep running | colrm 8 | xargs -L 1 -t vagrant halt
else
command vagrant "$@"
fi
}
# For macOS users
# Piece of code to be included in your ~/.profile file.
# Typing `vagrant halt all` in your terminal will then halt all the running vagrant VMs.
vagrant() {
if [[ $@ == "halt all" ]]; then
command vagrant global-status | grep running | colrm 8 | xargs -L 1 -t vagrant halt
else
command vagrant "$@"
fi