DEV Community

Cover image for How Tagging Resources Can Reduce Your AWS Bill
Tony Chan
Tony Chan

Posted on

How Tagging Resources Can Reduce Your AWS Bill

Amazon AWS has revolutionized everything from simple file storage to complex data processing tasks. From students to Fortune 100 companies, anyone can tap virtually limitless storage and processing power in just minutes.

But with great power comes great responsibility: The pay-as-you-go pricing structure makes it just as easy to rack up enormous bills. It's easy for companies to 'set and forget' their AWS infrastructure until it grows out of control.

Fortunately, there are simple tools and strategies that you can put in place to manage your costs. The key is recognizing the need to monitor costs early on and putting the right processes in place to ensure everyone is kept up-to-date.

Let's take a look at why AWS tags are the best starting point for cost management and how you can get started with them.

Amazon AWS has made it possible to provision resources in minutes — but it's just as easy to rack up large bills without the right cost monitoring in place.

What Are AWS Tags?

Amazon AWS enables users to assign metadata to their resources in the form of tags — or simple labels that consist of a key and optional value. You can use tags to manage, search for, and filter resources, which makes it much easier to manage them.

There are two different types of cost allocation tags:

  • User-defined Tags: These tags can include anything that you’d like to track, ranging from projects to cost centers. Just don’t include any sensitive information in them! The easiest way to add them is by using the AWS Tag Editor.
  • AWS-generated Tags: These are “createdBy” tags that are automatically created by AWS. You can activate these tags in the AWS Management Console in the Billing and Cost Management console under Cost Allocation Tags.

AWS Cost Explorer and Cost and Usage Report files (CUR) can break down AWS costs using these tags. You can easily see what business units, projects, customers, or cost centers are generating the highest expenses and address them before they become a problem.

For example, the following report shows tags in each column and costs in each row, demonstrating how you can drill down into resource usage:

Alt Text
Cost Allocation Report Example - Source: Amazon AWS Docs

Cost allocation reports are generated as a comma-separated value (CSV) file that can be easily analyzed by third-party reporting tools or turned into visualizations.

It’s important to note that cost allocation tags can take up to 24 hours to appear in the Billing and Cost Management console, but you can speed up the process with a manual refresh.

Getting Started with Tags

The best way to get started with tags is to come up with a standardized set of resource tags to use throughout your organization. For instance, do you want to track costs by project, department or other metrics? What is the name of these tags?

If you have existing tags, you can identify and programmatically standardize them using tools like the Resource Groups Tagging API, AWS Config Rules, custom scripts, or by manually using the AWS Tag Editor and billing reports. This is known as reactive governance.

Alt Text
Example of Rule Parameters - Source: Amazon AWS Docs

The example above shows a series of required tags specified in an AWS Config Rule. If the "Value" is missing, that means that the tag is optional, while specific values mean that the tag must include one of the values in order to be valid.

You can check for invalid tags on resources by setting up custom rules. In the example below, the rule checks EC2 instances to ensure that they contain required tags and flag any instances that don’t adhere to the standard.

Alt Text
Example of Required Tags on EC2 - Source: Amazon AWS Docs

If you already use standardized tags or are starting from scratch, you can move straight to tools like AWS CloudFormation, AWS Service Catalog, or IAM resource-level permissions to enforce standardized tags during resource creation. This is known as proactive governance.

Alt Text
Tag Library Workflow - Source: Amazon AWS Docs

The AWS Service Catalog TagOption Library is one of the easiest ways to create tag templates. By associating TagOptions for different products, the tool aggregates the associated product TagOptions and applies them to each newly provisioned product.

The Bottom Line

It's easy for AWS costs to spin out of control over time, but fortunately, tagging can help you monitor and proactively address these rising costs.

Tracking AWS costs can help you save thousands or tens of thousands of dollars over time by cutting waste and streamlining usage. It’s important to implement these efforts with the support of both engineers and management and ensure smooth communication.

Top comments (0)