hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.65k forks source link

Support for time_period_from and time_period_to arguments in azurerm_subscription_cost_management_export #22391

Open YoshicoppensE61 opened 1 year ago

YoshicoppensE61 commented 1 year ago

Is there an existing issue for this?

Community Note

Description

In ARM and on Azure you can add a OneTimeExport, to do a historical cost export, where you provide some dates as boundaries for you cost export. Unfortunately in azurerm currently, it is not possible to set these dates as they are no arguments in the resource.

So I would propose to use time_period_from and time_period_to as extra arguments, in the export_data_options block. They only are useful, when the timeframe argument is set to 'Custom' (which is already allowed in the current azurerm implementation). So probably we would need some validation there, to make sure they are only able to be used when timeframe is set to 'Custom'

You could also add a timePeriod block with then a "to" and "from" argument, bit similar to AzApi implementation and ARM itself, do not really mind either, but in the same resource here, recurrence_period_start_date and recurrence_period_end_date are also separate arguments (instead of in a block)

New or Affected Resource(s)/Data Source(s)

azurerm_subscription_cost_management_export

Potential Terraform Configuration

resource "azurerm_subscription_cost_management_export" "export" {
  name                         = var.export_name
  subscription_id              = data.azurerm_subscription.subs.id
  recurrence_type              = var.recurrence
  recurrence_period_start_date = var.recurrence_period_start_date
  recurrence_period_end_date   = var.recurrence_period_end_date
  active                       = var.active

  export_data_storage_location {
    container_id     = data.azurerm_storage_container.container.resource_manager_id
    root_folder_path = var.folder_path
  }

  export_data_options {
    type       = var.type
    time_frame = var.timeframe
    time_period_from = "2023-04-05"
    time_period_to = "2023-07-04"
  }
  provider                        = azurerm.analytics
}

References

https://learn.microsoft.com/en-us/azure/templates/microsoft.costmanagement/exports?pivots=deployment-language-arm-template

BeeDeeBePope commented 3 months ago

Looking forward to this. Is it planned for the near future?