Warning
There is no "stable" version. This tool is under development. The only version by the moment is 0.4.0.
Wrapping some awscli commands with beautiful TUI
Build with ❤ in Python
Table of Contents generated with DocToc
- Why cloudsnake
- Badges
- Available implementations
- Examples
- Installation
- Uninstall
- Local development
- TO DO
- Improvements
- TOP LINKS
- Poetry commands
- Cloudsnake commands
- License
The main intention of this tool is to continue improving my python skills, get to know the AWS boto3 SDK better, and learn how to create a CLI using typer, rich, and textual. The tool tries to implement some commands from the official AWS cli (aws cli), adding my own logic and with highlights (pretty print json output/table with typer/rich).
Important
Do not try to use part of this code in a productive app as it is currently untested. (visit #TO DO section). I also don't know if this is the best way to use any of the tools that the application uses (boto3, typer, rich...), that is why any PR is welcome, it will be appreciated so I can continue improving my skills.
Important
In the end, the purpose of this tool is also to be able to facilitate the day to day, creating tools that help me to operate the platform. For example, to quickly connect to EC2, RDS...etc.
Code | |
CI/CD | |
Package | |
Meta | |
Linter |
-
Connect to EC2 instances using SSM. You can pass the instance id (
--target
) or use the interactive menu (--with-instance-selector
) -
Connect to the RDS instances using IAM db authentication.
See examples in the next section
For the examples, you need to be authenticated to AWS account using your local credentials.
In your terminal, set the corresponding AWS_PROFILE=MyProfile
if not using the default. (~/.aws/credentials
)
cloudsnake ssm start-session --with-instance-selector # will print all your instances in a terminal menu
cloudsnake ssm start-session --target i-XXXXXX # connect to the instance specifying the target id
Please follow this instructions to setup your RDS IAM authentication.
By default, cloudsnake
forces to use TLS/SSL connections.
cloudsnake rds download-cert --save-path /tmp
Other region:
cloudsnake --region us-east-1 download-cert --save-path /tmp
Example for the region eu-west-1
:
cloudsnake rds connect -h XXXXX.XXXXXX.eu-west-1.rds.amazonaws.com -u ADMIN --cert /tmp/rds-cert-eu-west-1.pem
pip3 install cloudsnake
Warning
Probably your system will not allow this installation method due to a broken system package.
Example error
Error:
error: externally-managed-environment× This environment is externally managed ╰─> To install Python packages system-wide, try 'pacman -S python-xyz', where xyz is the package you are trying to install.
If you wish to install a non-Arch-packaged Python package, create a virtual environment using 'python -m venv path/to/venv'. Then use path/to/venv/bin/python and path/to/venv/bin/pip. If you wish to install a non-Arch packaged Python application, it may be easiest to use 'pipx install xyz', which will manage a virtual environment for you. Make sure you have python-pipx installed via pacman.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.
Install pipx
with your system package manager (apt
, dnf
, pacman
...).
pipx install cloudsnake
git clone https://github.com/containerscrew/cloudsnake.git
cd cloudsnake
make pipx-local-install
pip3 uninstall cloudsnake
pipx uninstall cloudsnake
git clone https://github.com/containerscrew/cloudsnake.git
cd cloudsnake
make update
make run
make pre-commit-install
make run-pre-commit
git clone https://github.com/containerscrew/cloudsnake.git
cd cloudsnake
make run-tests
- Documentation with docstrings
- Add more tests with pytest and boto3 mock
- Remove @classmethod
- Ruff linter
- Cliff: changelog
- Pipelines with github actions. Automatic publish new version to
pypip
- Other...
cloudsnake --log-level debug --region us-east-1 --profile default ec2 describe-instance
cloudsnake ec2 describe-instances --log-level debug --region us-east-1 --profile default --other-specific-flags-for-this-subdommand
cloudsnake --help
cloudsnake ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].{Instance:InstanceId,VpcId:VpcId,AZ:Placement.AvailabilityZone,Name:Tags[?Key==`Name`]|[0].Value}' --output json
cloudsnake ec2 describe-instances --filters "Name=instance-state-name,Values=running" --output json
cloudsnake ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].{InstanceName:Tags[?Key==`Name`]|[0].Value}' --output json
cloudsnake ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].Tags[?Key==`Name`].Value[][]'
cloudsnake rds describe-db-instances --query 'DBInstances[*].DBInstanceIdentifier'
cloudsnake ssm start-session --with-instance-selector
cloudsnake ssm start-session --target i-xxxxxxx
cloudsnake
is distributed under the terms of the MIT license.