Skip to content
/ awstools Public

POSIX shell scripts for simplified AWS resource management with tag filtering and Docker-based tools

License

Notifications You must be signed in to change notification settings

kjiwa/awstools

Repository files navigation

AWS Shell Tools

POSIX-compliant shell scripts for AWS resource management. Connect to EC2 instances and RDS databases, run AWS commands in containers, with tag-based filtering and minimal dependencies.

Tools

awsenv - Run AWS CLI and scripts in Docker without local installation. Handles credentials, mounts directories, installs packages on demand.

ec2client - Connect to EC2 instances via SSH or SSM. Filter by tags, select interactively, auto-connect when one match found.

rdsclient - Connect to RDS/Aurora databases with auto-detected authentication (IAM, Secrets Manager, or manual).

Common Features

  • Multiple tag-based filtering (AND logic)
  • Interactive selection when multiple matches
  • Auto-connect with single match
  • POSIX-compliant (sh, dash, bash, zsh)
  • Docker-based isolation

Examples

# Connect to EC2 via SSM
ec2client -t Environment=production

# Multiple tag filters (AND logic)
ec2client -t Environment=prod -t Team=backend

# Connect to RDS with IAM
rdsclient -t Application=api -a iam

# Multiple database filters
rdsclient -t Environment=prod -t Application=analytics

# Run AWS commands in container
awsenv aws s3 ls
awsenv -p jq ./process-data.sh

Usage

Prerequisites

  • Docker
  • AWS credentials
    • AWS CLI configuration files (~/.aws/config, ~/.aws/credentials)
    • Or environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

Run Without Installation

The scripts work directly without installation:

chmod +x *.sh
./ec2client.sh -t Environment=staging
./rdsclient.sh -t Team=backend -a iam
./awsenv.sh aws ec2 describe-instances

Install for System-Wide Access

Installation makes the tools available system-wide and provides AWS CLI wrapper functionality.

Quick Install

# System-wide installation (requires sudo)
sudo ./install.sh -d /usr/local/bin -c bash

# User installation (no sudo required)
./install.sh -d ~/.local/bin -c bash
export PATH="$HOME/.local/bin:$PATH"  # Add to ~/.bashrc

The install script:

  • Copies tools to target directory without .sh extension
  • Creates AWS CLI wrapper scripts (aws, aws_completer, session-manager-plugin)
  • Optionally configures shell completion for bash or zsh

Manual Installation

# Copy scripts
sudo cp awsenv.sh /usr/local/bin/awsenv
sudo cp ec2client.sh /usr/local/bin/ec2client
sudo cp rdsclient.sh /usr/local/bin/rdsclient
sudo chmod +x /usr/local/bin/{awsenv,ec2client,rdsclient}

# Create AWS CLI wrappers
for cmd in aws aws_completer session-manager-plugin; do
  sudo tee /usr/local/bin/$cmd > /dev/null << 'EOF'
#!/bin/sh
exec /usr/local/bin/awsenv "$(basename "$0")" "$@"
EOF
  sudo chmod +x /usr/local/bin/$cmd
done

Shell Completion

Bash (~/.bashrc):

complete -C aws_completer aws

Zsh (~/.zshrc):

autoload -Uz compinit && compinit
complete -C aws_completer aws

Uninstall

# Remove installed files
sudo rm -f /usr/local/bin/{awsenv,ec2client,rdsclient,aws,aws_completer,session-manager-plugin}

# Remove completion (edit ~/.bashrc or ~/.zshrc manually)

About

POSIX shell scripts for simplified AWS resource management with tag filtering and Docker-based tools

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages