Resource
dcloud_cost_view
A saved cost explorer view — a named question such as "Shop by service, last month" — optionally mailed monthly (on the 2nd, for the month before) with its CSV.
Example Usage
resource "dcloud_cost_view" "shop_by_service" {
name = "Shop by service, last month"
description = "What the shop team spends, mailed to finance every month"
state = jsonencode({
range = { type = "relative", preset = "last-month" }
granularity = "day"
groupBy = { dimension = "service" }
filters = [{ dimension = "project", values = [dcloud_project.shop.id] }]
})
report = jsonencode({ enabled = true, recipients = ["finance@example.com"] })
}Schema
Required
name(String) 1–100 characters, trimmed; unique in the organization (409 when taken). Up to 100 characters.state(String) The question (JSON):{ range = { type = "relative", preset = "last-month" }, granularity = "day", groupBy = { dimension = "service" }, filters = [] }. Presets: last-7-days, last-30-days, last-90-days, month-to-date, last-month, last-3-months, year-to-date; or{ type = "fixed", start, end }. Write all four keys: the API fills in the ones left out. Usejsonencode.
Optional
description(String) Free text shown with the view, at most 500 characters; default none. Up to 500 characters.report(String) Mail it monthly (JSON):{ enabled = true, recipients = ["finance@example.com"] }.shared(Boolean) Visible to everyone with billing:GetCostAndUsage (default true), or only to its creator.
Read-Only
id(String) The resource's id.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import dcloud_cost_view.shop_by_service <cost-view-id>Generated from the provider's schema.
Related