Manic tools for manipulating sets of tagged resources in AWS.
Project description
Tagmania
📚 Project Resources
| 📖 Current Documentation | 🧪 Test report for last release |
|---|
Overview
Tagmania provides command-line tools for managing AWS EC2 clusters through tag-based operations. It offers utilities for starting, stopping, and creating snapshots of clusters identified by their "Cluster" tag.
Key Requirements:
- EC2 instances must have "Cluster" tag to identify cluster membership
- Instance "Name" tags are used for targeted operations
- AWS CLI profile configuration required for authentication
Installation
Quick Install
pip install tagmania
Version Management
For production environments, always pin to a specific version:
pip install tagmania==2.4.0
See Version Management for detailed guidance on version pinning and stability.
AWS Cost Warning
⚠️ Important: This tool operates on AWS infrastructure and can incur costs:
- EBS snapshot storage charges apply for all created snapshots
- Data transfer costs may apply when creating/restoring snapshots
- Test infrastructure in
template.yamlwill create billable EC2 instances - Always clean up test resources after use to avoid ongoing charges
For testing, consider using AWS Free Tier eligible instance types and remember to delete snapshots when no longer needed.
Available Commands
cluster-start- Start all instances in a clustercluster-stop- Stop all instances in a clustercluster-snap- Create, restore, delete, and list snapshots
Quick Start
Starting and Stopping Clusters
# Start all instances in a cluster
cluster-start production-cluster
# Stop all instances in a cluster
cluster-stop production-cluster
# Use specific AWS profile
cluster-start --profile myprofile production-cluster
Creating Snapshots
# Create a snapshot backup of entire cluster
cluster-snap --backup production-cluster
# Create a named snapshot
cluster-snap --backup --name daily-backup production-cluster
Restoring from Snapshots
# Restore entire cluster from default snapshot
cluster-snap --restore production-cluster
# Restore from named snapshot
cluster-snap --restore --name daily-backup production-cluster
Advanced Features
Targeted Restore
Restore specific instances within a cluster using regex pattern matching against instance "Name" tags:
# Restore only web servers
cluster-snap --restore --target ".*-web-.*" production-cluster
# Restore specific instance
cluster-snap --restore --target "server-01" --name daily-backup production-cluster
Common Targeting Patterns:
".*-web-.*"- All instances with "web" in the name"server-[0-9]+"- Instances named server-1, server-2, etc."prod-api-.*"- All production API servers"backup-db"- Specific instance named "backup-db"
Snapshot Management
# List all snapshots for a cluster
cluster-snap --list production-cluster
# List specific labeled snapshots
cluster-snap --list --name daily-backup production-cluster
# Delete specific snapshot set
cluster-snap --delete --name daily-backup production-cluster
# Delete all snapshots for cluster
cluster-snap --delete production-cluster
How It Works
Backup Process
- Stops all cluster instances
- Creates EBS snapshots of all attached volumes
- Tags snapshots with cluster and label information
- Instances remain stopped after backup (use
cluster-startto restart)
Restore Process
- Stops all cluster instances (or targeted instances)
- Detaches and deletes current EBS volumes
- Creates new volumes from snapshots
- Attaches new volumes to instances
- Instances remain stopped after restore (use
cluster-startto restart)
Targeted Restore Process
- Validates regex pattern
- Filters instances by Name tag matching pattern
- Displays matched instances for confirmation
- Performs restore only on matched instances
- Other instances in cluster remain unchanged
Safety Features
- Confirmation Required: All destructive operations require "yes" confirmation
- Cluster Isolation: Operations only affect instances with matching "Cluster" tag
- Automation Tracking: Uses "SNAPSHOT_MANAGER" key to track managed resources
- Regex Validation: Targeted operations validate regex patterns before execution
- Item Limits: Maximum 150 items processed per operation for performance protection
Version Management and Stability
To ensure consistent and stable deployments, it is critical to pin Tagmania to specific versions rather than using floating version numbers.
Recommended Installation Methods
pip with version pinning:
pip install tagmania==2.4.0
Poetry (recommended for projects):
[tool.poetry.dependencies]
tagmania = "2.4.0"
Requirements.txt:
tagmania==2.4.0
Version Selection Strategy
Production Environments:
- Always use exact version pinning (e.g.,
==2.4.0) - Test new versions in development/staging before production deployment
- Document version upgrade procedures and rollback plans
- Monitor release notes for breaking changes
Development Environments:
- Use compatible version ranges for feature development (e.g.,
~=2.4.0) - Pin to exact versions when reproducing production issues
- Update regularly to stay current with security patches
Checking Installed Version
pip show tagmania
Or within Python:
import tagmania
print(tagmania.__version__)
Upgrade Planning
# Create backup of current environment
pip freeze > requirements-backup.txt
# Upgrade to specific version
pip install tagmania==2.5.0
# Test functionality
cluster-snap --list test-cluster
# If issues occur, rollback
pip install tagmania==2.4.0
Contributing
We welcome contributions! Tagmania uses a fork-based development model to ensure code quality and maintain project integrity.
Please see our Contributing Guide for detailed instructions on:
- Setting up your development environment
- Creating and maintaining your fork
- Submitting pull requests
- Following our coding standards and commit conventions
Troubleshooting
- No instances found: Verify "Cluster" tag exists and matches exactly
- Invalid regex: Test regex patterns before using with targeted operations
- Permission errors: Ensure AWS profile has EC2 and EBS permissions
- Timeout issues: Large volumes may take time to snapshot/restore
- Python compatibility: Requires Python 3.9 or higher
Support
License
This project is licensed under the terms specified in the LICENSE file.
Sponsor
If you find this project useful, please consider sponsoring its development.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tagmania-2.5.0.tar.gz.
File metadata
- Download URL: tagmania-2.5.0.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbc95c704d9702e4ce53497accbd8c0cf481ba566e433f64399b3ed12b4e5bf1
|
|
| MD5 |
2a919d7d1fb8882772e1e5c4373820f4
|
|
| BLAKE2b-256 |
60687b2e4c78cecdb6b6d2235ace836ff2d882f794f80a6e0c37272a6d6c6518
|
Provenance
The following attestation bundles were made for tagmania-2.5.0.tar.gz:
Publisher:
pipeline.yaml on svange/tagmania
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tagmania-2.5.0.tar.gz -
Subject digest:
fbc95c704d9702e4ce53497accbd8c0cf481ba566e433f64399b3ed12b4e5bf1 - Sigstore transparency entry: 435168512
- Sigstore integration time:
-
Permalink:
svange/tagmania@2c4023b41a3910cc29f15679e735301e2535701c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/svange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yaml@2c4023b41a3910cc29f15679e735301e2535701c -
Trigger Event:
push
-
Statement type:
File details
Details for the file tagmania-2.5.0-py3-none-any.whl.
File metadata
- Download URL: tagmania-2.5.0-py3-none-any.whl
- Upload date:
- Size: 28.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
138a2bb6225a9e0f385b8a56e63fbe992f8d676680c7ab984e86236b4c571496
|
|
| MD5 |
fa031df692dc4227f4021fc66e33b3a6
|
|
| BLAKE2b-256 |
73883dfdef409cfd9665477b4e66f5cafc9542b2b7f2a858d088f72149dfbf0c
|
Provenance
The following attestation bundles were made for tagmania-2.5.0-py3-none-any.whl:
Publisher:
pipeline.yaml on svange/tagmania
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tagmania-2.5.0-py3-none-any.whl -
Subject digest:
138a2bb6225a9e0f385b8a56e63fbe992f8d676680c7ab984e86236b4c571496 - Sigstore transparency entry: 435168546
- Sigstore integration time:
-
Permalink:
svange/tagmania@2c4023b41a3910cc29f15679e735301e2535701c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/svange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yaml@2c4023b41a3910cc29f15679e735301e2535701c -
Trigger Event:
push
-
Statement type: