Tagging Cloud Resources with Komiser
Tags: aws, devops, cloud, opensource
Published: 2023-01-24 16:10:33

## Why Tagging

As cloud infrastructure becomes more complex, teams often have difficulty managing the large number of resources that are constantly changing, expanding, and evolving. Resources can be shared between multiple teams and created in different regions and cloud providers, making it difficult for teams to keep track of their resources.

Effective tagging can help with this by providing visibility into the specific resources being used, who is using them, and the purpose for which they were created. Tagging also provides an effective means of allocating expenses to the correct cost centers.

In this post, we will showcase how to develop an efficient tagging strategy using Komiser, an open-source cloud-agnostic resource manager. However, before discussing the management of tags, we need to first list all the resources of our cloud infrastructure. Fortunately, with the help of Komiser, you can easily create a list of your cloud assets in just a matter of seconds.

[Learn more about the importance of tagging](https://www.tailwarden.com/blog/tagging-optional).

> _In the upcoming section, we will focus on using Komiser with AWS, but the workflow can be applied to all the other cloud providers that Komiser supports._

## Resources Discovery

With [Komiser](https://github.com/tailwarden/komiser), you can connect multiple cloud accounts, and build your cloud inventory in seconds. In the example below, we’ve connected an AWS production and sandbox accounts:

![Connecting multiple AWS accounts with config.toml](https://miro.medium.com/max/700/0*tdpGqb-EPTlKswcG.png)

Once the cloud accounts have been integrated with Komiser and the correct set of [permissions](https://github.com/tailwarden/komiser/blob/master/policy.json) has been given, Komiser will begin syncing your AWS cloud accounts cost data and resource metadata as shown in the logs below:

![Komiser fetches resources across all regions](https://miro.medium.com/max/700/0*sBmwaLREE1nVY9QU.png)

From there, you can access the Komiser dashboard by pointing your favorite browser to port 3000. Komiser comes with a resource inventory feature where you can have an active resource inventory of all your cloud resources along with relevant information such as source account, region, cost, and the tags that are applied to it.

Below is an example of what the inventory page looks like after connecting the AWS accounts:

![Inventory with active resources](https://miro.medium.com/max/700/0*IyZLWZf4J3_P0gVs.png)

With the resources list automatically generated, we can now begin managing tags from a single centralized dashboard.

## Use cases

The Inventory feature enables users to filter their resources using built-in fields and metadata, such as tags, resource names, cloud providers, services, etc. By combining these filters with tags, we highlight through common use cases, how powerful and effective they can be.

### 1 — Identifying Untagged Resources

Infrastructure as Code (IaC) tools like Terraform and CloudFormation have made it easier to create new resources in the cloud, but this can also lead to forgetting to enforce tagging policies at creation time. Keeping track of resources being created and used in an AWS account can be difficult, but with the right tools, it doesn’t have to be.

With Komiser, you can search for non-tagged AWS resources by using the “_All tags_” field combined with the “_which are empty_” operator.

You should be presented with a list of AWS resources in all regions that need to be tagged as seen below.

![Identifying untagged resources](https://miro.medium.com/max/700/0*tvYdnCnJ39jj6JhP.png)

As seen in the results above, there are 535 resources across our multi-AWS accounts infrastructure, with a total cost of $475. To identify resources that are driving costs and are not tagged, we can filter the results by selecting the “_Cost_” field from the “_Filter by_” dropdown and using the “_is greater than_” operator. In the value field, type 0 to list all resources that have a cost greater than 0$.

![Identifying resources driving AWS costs](https://miro.medium.com/max/700/0*CHuARwp1Fi1LR5N4.png)

After filtering the results, we found 69 resources across 3 regions that needed to be tagged. To further evaluate these resources, we can also check if they are running in a sandbox environment, as they may not be critical for production usage and can be deleted or stopped during non-business hours.

![Filtering resources by environment](https://miro.medium.com/max/700/0*ylvtPd8oAovfAQVP.png)

With resources being accurately identified by tags, you can gain a comprehensive understanding of your cloud costs, pinpoint resources that are either redundant or aren’t being used, and identify potential opportunities to save money.

### 2 — Grouping Resources by Teams

By using filters and tags, you can group and organize your cloud resources based on projects, environments, departments, or teams, which in turn can increase the visibility and transparency of cloud usage and help in allocating expenses to the appropriate cost centers.

In the following example, you can see resources created at any given time and the people who are using them (e.g: _Author=mlabouardy_), and make them accountable for cost optimization ([Enabling and maintaining a cost-conscious culture. At every level](https://www.tailwarden.com/blog/enabling-and-maintaining-a-cost-conscious-culture-at-every-level))

![Filtering resources by the owner](https://miro.medium.com/max/700/0*M0Ofk3ly4Mxe4v3t.png)

Another option is to list cloud resources created by each team. For example, resources created by the frontend developers can be listed by filtering resources where the “_Team_” tag equals “_Frontend_”.

![Filtering resources by team or project](https://miro.medium.com/max/700/0*vRdPb4BZEpcg3g8I.png)

Optionally, you could create custom views for your teams with a filtered list of their cloud resources. For example, you can create a view that holds resources associated with your frontend team and another view for the backend team.

![Grouping resources by teams](https://miro.medium.com/max/700/0*q1INA_bhX3OMLJsg.png)

This provides a convenient way to have an instant monitoring dashboard for your teams created directly from Komiser and transfer the incentive of cost reduction down to the individual team member level so that your teams can feel incentivized to make a difference.

### 3 — Bulk Tagging Resources

You can use bulk actions to add tags to multiple resources at a time, or quickly navigate to the resources in the appropriate service console to take actions (e.g. deleting under-utilized resources).

In the example below, we’ve selected resources from different cloud accounts (Sandbox and Production) and regions.

![Bulk tags management](https://miro.medium.com/max/700/0*njxCUIObHhaPO0aM.png)

By clicking on the “_Bulk manage tag_s” action, a side panel will appear, where you can add multiple key-value pairs. Once finished, the tags will be added to the selected resources, allowing you to quickly identify and filter resources that need extra monitoring.

![Adding tags to multiple resources](https://miro.medium.com/max/700/0*Icj6LUTFdnZRKuAi.png)

Bulk tags can be used to monitor resources that require extra security measures. Many organizations have cloud workflows that involve confidential and sensitive information that needs to be constantly and strictly protected. By tagging these sensitive resources, it provides the necessary visibility to keep track of important deployments and identify dormant and unknown resources.

By implementing a tagging strategy that incorporates open-source tools like Komiser, organizations can significantly enhance productivity (avoid context switch between cloud providers’ consoles), optimize their cloud costs, and better manage their deployed cloud resources.

> Regardless if you are a Developer, DevOps, or Cloud engineer. Dealing with the cloud can be tough at times, especially on your own. If you are using Tailwarden or Komiser and want to share your thoughts doubts and insights with other cloud practitioners feel free to join our [_Tailwarden discord server_](https://discord.tailwarden.com/). Where you will find tips, community calls, and much more.