cloudsnake 🐍
Wrapping some useful AWS cli commands to operate some services like EC2, SSO, SSM, Cloudwatch and more
In your terminal, set the corresponding AWS_PROFILE=MyProfile if not using the default. (~/.aws/credentials). Copy this helper function called aws-profile into your favourite shell (.bashrc, .zshrc, ~/.config/fish/function) to easily switch between AWS profiles. In case of using fish shell, use this other function.
aws-profile
Profile, region & log level
--profile/-p, --region/-r and --log-level/-l are global options. Pass them right after cloudsnake and they apply to the subcommand that follows:
cloudsnake --profile prod --region us-east-1 ssm get-parameters
cloudsnake --log-level debug trail events
--region and --profile can also be passed after the subcommand to override them per command (handy for aliases and quick one-offs):
# Equivalent to the global form above
cloudsnake ssm get-parameters --region us-east-1 --profile prod
cloudsnake secrets-manager get-secrets -r us-east-1 -p prod
When omitted, region defaults to eu-west-1 and profile to your AWS_PROFILE environment variable.
SSM session
Install the REQUIRED plugin to use SSM sessions.
cloudsnake ssm start-session -is # will print all your instances in a terminal menu
cloudsnake ssm start-session --target i-XXXXXX # connect to the instance specifying the target id
SSM parameter
cloudsnake ssm get-parameter # default region eu-west-1
cloudsnake --region us-east-1 ssm get-parameters # specify region
SSO Credentials
cloudsnake --region eu-west-1 sso get-credentials --start-url https://myapp.awsapps.com/start
Cloudwatch log stream
# Opens an interactive menu to select the log group
cloudsnake logs stream
# Streams logs from 1 day ago with a filter pattern "deleting"
cloudsnake logs stream --since 1d --log-group /aws/lambda/my-function-name --filter-pattern "deleting"
# Streams (tails) logs starting from the moment you execute the command
cloudsnake logs stream --log-group /aws/lambda/my-function-name
# Streams logs from a specific window (between 30 mins ago and 1 min ago)
cloudsnake logs stream --since 30m --end 1m --log-group /aws/lambda/my-function-name
CloudTrail events
# Monitor recent activity from the last 15 minutes (default)
cloudsnake trail events
# Look back 10 minutes
cloudsnake trail events --since 10m
# Look back 1 hour
cloudsnake trail events --since 1h
# Look back 1 day
cloudsnake trail events --since 1d
# Fetch events once and exit (no follow)
cloudsnake trail events --since 1h --once
# Watch only write (mutating) API calls
cloudsnake trail events --write-only --since 1h
# Watch only read-only API calls
cloudsnake trail events --read-only
# Filter by a specific AWS action
cloudsnake trail events --event DeleteTable
cloudsnake trail events --event TerminateInstances
# Filter events by a specific user
cloudsnake trail events --user john.doe
# Filter events by a specific resource
cloudsnake trail events --resource i-0123456789abcdef
# Search for an error message across all JSON bodies
cloudsnake trail events --search AccessDenied --since 6h
# Search for an IP address
cloudsnake trail events --search 203.0.113.15 --since 1d
# Dot-path structured search
cloudsnake trail events --search requestParameters.instanceId=i-0123456789abcdef
cloudsnake trail events --search userIdentity.type=AssumedRole
# Combine server-side filtering with client-side search (advanced)
cloudsnake trail events --event StopInstances --search Unauthorized --since 12h
# Full JSON output
cloudsnake trail events --output json
# NDJSON output (pipe-friendly)
cloudsnake trail events --output ndjson
cloudsnake trail events --output ndjson | jq '.EventName'
# Inline jq filtering
cloudsnake trail events --jq '.userIdentity.type == "AssumedRole"'
cloudsnake trail events --output ndjson --jq '.EventName'
# Scriptable examples
# Count API calls by type in the last hour
cloudsnake trail events --output ndjson --since 10m \
| jq -r '.EventName' | sort | uniq -c
# Find delete or terminate actions in the last 24 hours
cloudsnake trail events --output ndjson --since 24h \
| jq 'select(.EventName | test("Delete|Terminate"))'
Secrets Manager
cloudsnake secrets-manager get-secrets
cloudsnake --region us-east-1 secrets-manager get-secrets
# Password generator
cloudsnake secrets-manager generate-password --password-length 30
cloudsnake secrets-manager generate-password --help # for more options
Installation
Using pipx (Recommended)
Install pipx with your system package manager (apt, dnf, pacman...).
pipx install cloudsnake
Using pip
pip3 install cloudsnake
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.
Upgrade
pipx upgrade cloudsnake
Uninstall
pipx uninstall cloudsnake
# or
pip3 uninstall cloudsnake
Debug AWS SDK API calls
cloudsnake --log-level debug command subcommand [options]
License
cloudsnake is distributed under the terms of the GPL3 license.
Metadata
Release files for cloudsnake 0.16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cloudsnake-0.16.0.tar.gz | 47.5 kB | Without provenance | Details for cloudsnake-0.16.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cloudsnake-0.16.0-py3-none-any.whl | Python 3 | none | any | Details for cloudsnake-0.16.0-py3-none-any.whl |
Total release size: 94.8 kB
Release files / cloudsnake-0.16.0.tar.gz
| Download URL | cloudsnake-0.16.0.tar.gz |
|---|---|
| Size | 47.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35e893add32a2b8b0c6f0703b8ea06be37e6ce18583543fad924cb74addc9b10
|
|
BLAKE2b-256 checksum How to use checksums |
b013294eeefcb6fcea18632cd3021a74505f320a4da2a113d787cb5c120e418b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.5 Linux/6.17.0-1018-azure
|
Release files / cloudsnake-0.16.0-py3-none-any.whl
| Download URL | cloudsnake-0.16.0-py3-none-any.whl |
|---|---|
| Size | 47.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6daf613662795cbae4b507fb6e7c8c5f000363990b44562c54f4b20b9455f44c
|
|
BLAKE2b-256 checksum How to use checksums |
d6a9a300d0e0cc1f14cb2a9d7f1ac620cc7c6fe619bd0e12e0167cd5e4045d86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.5 Linux/6.17.0-1018-azure
|
Security for cloudsnake 0.16.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.