Easily build complex reports
Monitoring and efficiency metrics
Custom cost allocation tags
Network cost visibility
Organizational cost hierarchies
Budgeting and budget alerts
Discover active resources
Consumption-based insights
Alerts for unexpected charges
Automated AWS cost savings
Discover cost savings
Unified view of AWS discounts
COGS and business metrics
Model savings plans
Collaborate on cost initiatives
Create and manage your teams
Automate cloud infrastructure
Cloud cost issue tracking
Detect cost spikes
by Danielle Vansia
Contents
In this demo, we show how to create a set of virtual tags in Vantage. We’ll create a script that uses the Vantage Terraform provider. This script will automate the process of creating cross-provider tags for a set of teams. Organizations who use Infrastructure as Code and want to create a better culture of showback can use this script to easily set up multiple cross-provider tag keys and values via Terraform.
According to the FinOps Foundation, showback “creates a structure in which actual consumption of IT services is shown to business units, while the spend is being charged to a different business unit.” Therefore, a team or business unit may not be the ones footing the bill, but they are given a picture of how much they contribute to overall costs. Virtual tags enhance the practice of showback by providing a consistent and accurate way to tag and track cloud costs across multiple providers. You can use a third-party tool, like Vantage, to create these virtual tags, combining costs from multiple providers into one tag. For example, if you have AWS resources tagged by a specific team and costs in Azure also tagged by the same team, you can create external virtual tags that combine both sets of costs into one. Then, you can easily group by this tag within a report to show each team’s cost share.
You currently tag AWS and Kubernetes resources with tags that identify owners by team. To more easily show back each team’s share of costs in reporting, you decide to create a group of virtual tags that combine the AWS and Kubernetes costs into one tag value for each team. You will use the Vantage Terraform provider to easily automate this process for hundreds of team tags.
This tutorial assumes you have intermediate knowledge of Terraform. You should know how to create a basic configuration, have a basic understanding of for loops, and have an understanding of how to use variables.
for
For Vantage, you’ll need an active account and at least one provider integration. You’ll also need a Vantage API token with READ and WRITE scopes enabled.
READ
WRITE
All demo files are also included in the FinOps as Code demo repo.
To begin, create a new project directory and move to it.
mkdir terraform-tags && cd terraform-tags
Create a Terraform configuration file and call it tags-vantage.tf. Create providers.tf to store the provider configuration.
tags-vantage.tf
providers.tf
touch tags-vantage.tf touch providers.tf
You’ll also need to store the Vantage API token. You can export this token as an environment variable.
export VANTAGE_API_TOKEN=<YOUR_VANTAGE_API_TOKEN>
Open providers.tf and add the following block that initializes the Vantage provider. You do not need to set any additional configuration options since you already exported the Vantage API token.
terraform { required_providers { vantage = { source = "vantage-sh/vantage" } } }
Save and run the init command to initialize the configuration and download the latest provider for Vantage.
init
terraform init
As your organization’s FinOps champion, you already know the names of each team, which are also used for tagging purposes. These names are currently stored in a single-column CSV file, which you can decode and iterate over in your configuration. For this demo, we’ll create a local variable that holds the CSV content and another that decodes it; however, this file would most likely be in an external location. We’ll include five team names, but this configuration is scalable and can easily iterate over a file with hundreds of values.
See the Terraform documentation for more information on working with CSV files.
Open tags-vantage.tf and create the following local variables.
locals { team_csv_content = <<-CSV teams integrations security ingestion analytics core CSV all_teams = csvdecode(local.team_csv_content) }
Next, create your virtual tags using the vantage_virtual_tag_config Terraform resource. This resource block will iterate over the local all_teams variable to create one tag key that has multiple associated tag values, with their filters.
vantage_virtual_tag_config
all_teams
resource "vantage_virtual_tag_config" "team_tag" { key = "team_virtual_tag" backfill_until = "2024-01-01" overridable = false values = [ for t in local.all_teams : { name = t.teams filter = <<-FILTER (costs.provider = 'aws' AND (tags.name = 'team' AND tags.value = '${t.teams}')) OR (costs.provider = 'kubernetes' AND (tags.name = 'organization/team' AND tags.value = '${t.teams}')) FILTER } ] }
The above block performs the following actions:
key
backfill_until
overridable
false
values
name = t.teams
teams
t
filter
t.teams
team
organization/team
Save your configuration and deploy it with the plan and apply commands:
plan
apply
terraform plan terraform apply
In Vantage, you should see a new virtual tag, with corresponding values for each team, has been created.
Virtual Tags screen with new virtual tags from the script
If you create a new Vantage Cost Report and group by this new virtual tag, costs for each team are displayed as one line item within the report.
Vantage Cost Report grouped by the new team virtual tag
These new tags can easily help you show back the total costs attributed to each team as they are combined to one line item, across providers.
Congratulations—you just created a set of virtual tags to help your organization streamline its showback strategy. Check out our other FinOps as Code demos for other ways to automate your FinOps practice.
MongoDB Atlas is the cost-effective choice for production workloads where high-availability is a requirement.
Grafana is a strong competitor to the monitoring and observability features of Datadog for a fraction of the price.
AWS is implementing a policy update that will no longer allow Reserved Instances and Savings Plans to be shared across end customers.