Skip to main content

A tool for simplifying swarming of fixing AWS tags

Project description

aws-tag-a-day

A tool for simplifying multiple people fixing tags by proposing a tag a day for resources with those missing tags.

Build Status

Installation

pip install aws-tag-a-day

Quickstart

# Generate configuration file
mkdir -p ~/.config/tagaday/
cat > ~/.config/tagaday/config.yml <<EOY
dynamodb-table-name: 'tag-proposals'
dynamodb-table-region: 'us-east-1'
services:
- rds
- ec2
- s3
regions:
- us-east-1
required-tags:
- Project
- Owner
- Name
EOY

# Create dynamodb table defined in the above config file.
# If the table exists already, the utility will not overwrite it.
tag-a-day-initialise

# Start proposing tags
tag-a-day

Motivation

There are a lot of tools for handling batch tagging, but not many tools for aiding in filling in empty tags on a large scale.

The suggested workflow is:

  1. Create configuration file.
  2. Create a DynamoDB table by running tag-a-day-initialise. This is not a destructive operation, and existing tables will not be modified or removed. The utility will throw an error if the table already exists.
  3. Have 1 or more people start using tag-a-day.
  4. Reconcile any divergent or duplicate tags by running tag-a-day-reconcile, and discuss any duplicate tagging suggestions.
  5. Apply the tags to the resources.

NOTE: Steps 4 and 5 are not yet implemented by this utility.

Reference

Supported Services

Configuration File

CLI options

Extending

aws-tag-a-day is built on a plugin architecture, using entry_point in setuptools.

To add more TagHandlers, you can either add classes to this repo, or create a new python package with its own setup.py, and hook into the plugin architecture using the tag_a_day.tag_handlers entrypoint.

  1. Create a new class, inheriting from tag_a_day.services.service.Service

    from tag_a_day.services.service import Service
    
    class CustomTagHandler(Service): pass
    
  2. Set a unique name for the Tag handler

    from tag_a_day.services.service import Service
    
    class CustomTagHandler(Service):
       name='custom_handler'
    
  3. Create two stub methods, resources and handler matching the signatures below:

    from tag_a_day.services.service import Service
    
    class VpcTagHandler(Service):
       name='ec2_vpc'
    
       def resources(self, session):
         pass
    
       def handler(self, resource, expected_tags, region, session, cache, proposals):
         pass
    
  4. Implement resources(...) to return an iterable. If using boto3 resources, this should look like:

      def resources(self, session):
        return session.resource('ec2').vpc.all()
    

    If using boto3 client, don't forget to implement pagination, and should look like:

      def resources(self, session):
        ec2 = session.client('ec2')
        paginator = ec2.get_paginator('describe_vpcs')
    
        for page in paginator.paginate():
          for vpc in page:
            yield vpc 
    
  5. Implement handle(...) to yield a payload describing the tag proposal (example is using boto3.resources):

      def handle(self, vpc, expected_tags, region, session, cache, proposals):
        # This boilerplate logic will handle checking the tags which have already been
        # evaluated for this user.
        evaluated_tags = self._progress.evaluated_tags(vpc.vpc_id)
        vpc_info, missing_tags = \
            self._build_tag_sets(expected_tags, evaluated_tags, vpc.tags)
    
        # Check if the user has proposed values for all the missing tags 
        if self._progress.has_finished(vpc.vpc_id, expected_tags):
            # Print a skip message
            self._skip(vpc.vpc_id)
            return
    
        if any(missing_tags):
          # Print information about this resource, which could be useful 
          # to provide context around tagging.
          self._print_table(
            ("VpcID", vpc.vpc_id),
            *vpc_info
          )
    
          # Build our user prompt to ask for new tags
          tag_prompt = self._build_tag_prompt(missing_tags)
          for tag_key in missing_tags:
            # Yield a proposal for a new tag key/value pair for the given
            # resource id.
            yield {
              'resource_id': vpc.vpc_id,
              'tag_key': tag_key,
              'tag_value': tag_prompt(tag_key),
            }
    

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-a-day-0.1.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

aws_tag_a_day-0.1.5-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file aws-tag-a-day-0.1.5.tar.gz.

File metadata

  • Download URL: aws-tag-a-day-0.1.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for aws-tag-a-day-0.1.5.tar.gz
Algorithm Hash digest
SHA256 714d646d0c0078b0342573c991b56f1b8e3b62e3d714aa5427211ef43f7e6059
MD5 9319bc281d68afb91b3001cd409b67b0
BLAKE2b-256 1ee220960fe02e898dc12a13cf0b249e36ecbfca7cf72b7482ce370bae8295a7

See more details on using hashes here.

File details

Details for the file aws_tag_a_day-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: aws_tag_a_day-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for aws_tag_a_day-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 74b25ccb76c9932ec0d29281d4dc0bad76f515c74aadf8bba26db8ada2221406
MD5 85278f8f766eb7a41c3242ea63ab3652
BLAKE2b-256 6bf1b3934ca53a42fe5571c5d01d7cfdf476bacc69d226e627ceb1c5df0593b7

See more details on using hashes here.

Supported by

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