Skip to main content

The unified tag manager for AWS resources

Project description

AWS Tag Tools

The Unified Tag Manager for AWS Resources

PyPI - Version PyPI - Python Version PyPI - License Static Badge

awstt

English 简体中文


Overview

AWS Tag Tools (AWSTT) is a powerful and versatile tool designed to manage resource tags of AWS services through a unified operation.

With this tool, you can easily set or unset tags for multiple resources across multiple regions with a single command, or list resources in bulk matching specific tag keys/values and resource attributes (e.g., EC2 instance types).

Features

  • Supports both command-line interface (CLI) and AWS Lambda function.
  • Supports various AWS services, see the detailed list in Supported Services.
  • Supports AWS partitions: 'aws', 'aws-gov', and 'aws-cn'.
  • Use JMESPath expressions to filter or select resources, see Using Selectors.
  • Support using Python expressions for keys or values, see Using Expressions.
  • Option to ignore existing tags or automatically record original values when force overwriting.
  • Automatically record original key/values when unsetting tags.
  • Option to log information to a file.

Usage

Prerequisites

  • Python 3.11 or higher is required.
  • If not explicitly specifying credentials (e.g., AK/SK or profile name), the AWS CLI credential must be configured.
  • IAM role with permissions for the specified AWS services. For example, to add tags to Amazon EC2 instances, you must have the following permissions:
    • ec2:DescribeInstances
    • ec2:CreateTags
    • tag:TagResource

Installation

pip install -U aws-tag-tools

Commands

# Add the tag 'tagged_by=awstt' to any supported resources across all regions
awstt set --tag tagged_by=awstt
# Add two tags 'tagged_by=awstt' and 'owner=AnyIons' to EC2 instances in 'us-east-1' and 'us-west-1' regions
awstt set --tag tagged_by=awstt,owner=AnyIons --region us-east-1,us-west-1 --resource ec2:instance
# Using the AWS CLI credential profile named 'china', unset tags with keys 'tagged_by' and 'owner' from any VPCs in the 'aws-cn' partition
awstt unset --tag tagged_by,owner --resource arn:aws-cn:ec2:*:*:vpc/* --profile china
# Unset tags with key 'owner' from RDS instances with 'Engine' as 'mysql'
awstt unset --tag owner --resource rds:instance --filter spec[?Engine=='mysql']
# List resources created 5 days ago with tag key 'created_at', comparing the value with a dynamic expression
awstt list --filter tags[?key=='created_at' && value < '${(now() + timedelta(days=-5)).strftime('%Y-%m-%d_%H:%M:%S')}']
# Execute operations using a configuration file and AK/SK
awstt exec --config action.json --access_key YOUR_AWS_ACCESS_KEY_ID --access_key YOUR_AWS_SECRET_ACCESS_KEY

[!TIP] Use awstt --help for more detailed information

Advanced Usage

You can use a JSON configuration file for complex operations, such as adding the tag owner=AnyIons to all resources, but not allowing overwriting existing owner tags on EC2 instances, while also adding the tag env=dev only for RDS resources.

Please refer to action-set-example and action-unset-example.

[!WARNING] Currently, it does not support overriding global tags with specific resource tag selectors when unsetting tags. For example:

{
  "tags": [
    "owner"
  ],
  "resources": [
    {
      "target": "arn:aws:ec2:*:*:volume/*",
      "tags": [
        "tags[?key=='owner' && value == 'aws-tag-tools'].key"
      ]
    }
  ]
} 

This tag selector "tags[?key=='owner' && value == 'aws-tag-tools'].key" will not take effect, and all tags with the key 'owner' will be unset.

License

MIT © 2020 AnyIons

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_tag_tools-1.1.1.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_tag_tools-1.1.1-py3-none-any.whl (57.8 kB view details)

Uploaded Python 3

File details

Details for the file aws_tag_tools-1.1.1.tar.gz.

File metadata

  • Download URL: aws_tag_tools-1.1.1.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0

File hashes

Hashes for aws_tag_tools-1.1.1.tar.gz
Algorithm Hash digest
SHA256 062c7aab83e77280098c30c3542d0e33a29ed25c8e35ad5a8d9b641a4b0fa45f
MD5 5d7f5eb42f8658cb91eddf18706c397d
BLAKE2b-256 7bf047218a55542bd4a55e56d8fd470ef3104e3230ed39469239b13b525b9139

See more details on using hashes here.

File details

Details for the file aws_tag_tools-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: aws_tag_tools-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 57.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0

File hashes

Hashes for aws_tag_tools-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fae9e01da43f30ac5d567620d2e142e07bc9958a39077c75c771923950667e75
MD5 ae06890cd2951017925d66d18fd0f937
BLAKE2b-256 3ffac484dab80f17c809783e484237583e0b5bfba546e2f91c355254dddd0d2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page