Use Vantage’s official Terraform provider and AWS integration module to automate cloud cost management infrastructure as code.
main.tf
variables.tf
cur_bucket_name
variable. For sub-accounts, you need to link access, but you don’t need to configure a CUR bucket.cur_bucket_name
variable is not included within the module configuration. As a result, an IAM Role is created, which Vantage can assume to ingest the cost and resource metadata that are displayed within the Vantage console. See the Terraform documentation for more details.
terraform import
is a command used in Terraform that allows you to bring existing infrastructure resources into Terraform management. This command helps integrate resources that were created outside of Terraform—such as those provisioned directly in the Vantage console or API—into Terraform’s state file. For example, if you initially set up your cost reporting resources through the Vantage console, you can use this command to import these resources into your Terraform state, which allows you to maintain a single source of truth for your infrastructure.
To use terraform import
, run the following command:
vantage_cost_report.demo_report
: The type of infrastructure component managed by Terraform (e.g., vantage_cost_report
); followed by a user-defined identifier assigned to a resource in your Terraform configuration.rprt_1abc23456c7c8a90
: Example of a Cost Report token
. This can be found in the URL for a report within the console or via the API.provider "vantage"{...}
block. Export your token with: export VANTAGE_API_TOKEN=<YOUR_API_TOKEN>
.vantage_folder
resource, with “AWS Costs” as the title.vantage_cost_report
resource using the token output from the vantage_folder
resource. The Cost Report will be stored in the newly created AWS folder. The Cost Report’s title is “AWS Costs.” In addition, the vantage_saved_filter
resource includes a filter
parameter that uses Vantage Query Language (VQL), a SQL-like language for querying cloud cost and usage data. Here, the filter is set to show only AWS costs. Set the groupings
parameter to have the report grouped by region and service.account_id
, billing_account_id
, charge_type
, cost_category
, cost_subcategory
, provider
, region
, resource_id
, service
, tag:<tag_value>
. Enter multiple groupings as comma-separated values: groupings=provider,service,region
.aws_db_instance
resource from the AWS provider. Then, create a saved filter using the output of the arn
from the RDS instance as part of the filter criteria.terraform-provider-vantage
GitHub repository.
terraform import
to Manage External Resourcesterraform import
command.
token
for this Cost Report. You can access this token
using one of the following methods:token
from the end of the URL (e.g., in https://console.vantage.sh/reports/rprt_123a47b5ba1234e1
, copy rprt_123a47b5ba1234e1
)./cost_reports
Vantage API endpoint. The token
is one of the values returned in the response.vantage_cost_reports
Terraform data source. You can call the data source and create an output value to access a list of Cost Reports.vantage_cost_report
Terraform resource that you want to update is defined in the configuration. Below it is defined with the current parameters.terraform import
command. Replace the placeholder <token>
with the token
you just obtained for the Cost Report.rprt_123a47b5ba1234e1
, run the following command:filter
parameter to reflect two different RDS instances.