Skip to content

azurermResourceGroupCostManagementExport

Manages a Cost Management Export for a Resource Group.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_1",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    location: azurermResourceGroupExample.location,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermStorageContainerExample =
  new azurerm.storageContainer.StorageContainer(this, "example_2", {
    name: "examplecontainer",
    storage_account_name: azurermStorageAccountExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageContainerExample.overrideLogicalId("example");
const azurermResourceGroupCostManagementExportExample =
  new azurerm.resourceGroupCostManagementExport.ResourceGroupCostManagementExport(
    this,
    "example_3",
    {
      export_data_options: [
        {
          time_frame: "WeekToDate",
          type: "Usage",
        },
      ],
      export_data_storage_location: [
        {
          container_id: azurermStorageContainerExample.resourceManagerId,
          root_folder_path: "/root/updated",
        },
      ],
      name: "example",
      recurrence_period_end_date: "2020-09-18T00:00:00Z",
      recurrence_period_start_date: "2020-08-18T00:00:00Z",
      recurrence_type: "Monthly",
      resource_group_id: azurermResourceGroupExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermResourceGroupCostManagementExportExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Cost Management Export. Changing this forces a new resource to be created.

  • resourceGroupId - (Required) The id of the resource group on which to create an export. Changing this forces a new resource to be created.

  • recurrenceType - (Required) How often the requested information will be exported. Valid values include annually, daily, monthly, weekly.

  • recurrencePeriodStartDate - (Required) The date the export will start capturing information.

  • recurrencePeriodEndDate - (Required) The date the export will stop capturing information.

  • exportDataStorageLocation - (Required) A exportDataStorageLocation block as defined below.

  • exportDataOptions - (Required) A exportDataOptions block as defined below.

  • active - (Optional) Is the cost management export active? Default is true.


A exportDataStorageLocation block supports the following:

  • containerId - (Required) The Resource Manager ID of the container where exports will be uploaded. Changing this forces a new resource to be created.

  • rootFolderPath - (Required) The path of the directory where exports will be uploaded. Changing this forces a new resource to be created.

\~> Note: The Resource Manager ID of a Storage Container is exposed via the resourceManagerId attribute of the azurermStorageContainer resource.


A exportDataOptions block supports the following:

  • type - (Required) The type of the query. Possible values are actualCost, amortizedCost and usage.

  • timeFrame - (Required) The time frame for pulling data for the query. If custom, then a specific time period must be provided. Possible values include: weekToDate, monthToDate, billingMonthToDate, theLastWeek, theLastMonth, theLastBillingMonth, custom.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Cost Management Export for this Resource Group.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Resource Group Cost Management Export.
  • read - (Defaults to 5 minutes) Used when retrieving the Resource Group Cost Management Export.
  • update - (Defaults to 30 minutes) Used when updating the Resource Group Cost Management Export.
  • delete - (Defaults to 30 minutes) Used when deleting the Resource Group Cost Management Export.

Import

Cost Management Export for a Resource Group can be imported using the resourceId, e.g.

terraform import azurerm_resource_group_cost_management_export.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CostManagement/exports/export1