Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_billing_account_cost_management_export, azurerm_resource_group_cost_management_export, azurerm_subscription_cost_management_export adding property file_format #27122

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion internal/services/costmanagement/export_resource_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ func (br costManagementExportBaseResource) arguments(fields map[string]*pluginsd
ValidateFunc: validation.IsRFC3339Time,
},

"file_format": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(exports.FormatTypeCsv),
ValidateFunc: validation.StringInSlice([]string{
string(exports.FormatTypeCsv),
// TODO add support for Parquet once added to the SDK
}, false),
},

"export_data_storage_location": {
Type: pluginsdk.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -195,6 +205,7 @@ func (br costManagementExportBaseResource) readFunc(scopeFieldName string) sdk.R
if err := metadata.ResourceData.Set("export_data_options", flattenExportDefinition(&props.Definition)); err != nil {
return fmt.Errorf("setting `export_data_options`: %+v", err)
}
metadata.ResourceData.Set("file_format", string(pointer.From(props.Format)))
}
}

Expand Down Expand Up @@ -267,7 +278,8 @@ func createOrUpdateCostManagementExport(ctx context.Context, client *exports.Exp
return fmt.Errorf("expanding `export_data_storage_location`: %+v", err)
}

format := exports.FormatTypeCsv
format := exports.FormatType(metadata.ResourceData.Get("file_format").(string))

recurrenceType := exports.RecurrenceType(metadata.ResourceData.Get("recurrence_type").(string))
props := exports.Export{
ETag: etag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ resource "azurerm_resource_group_cost_management_export" "test" {
recurrence_type = "Monthly"
recurrence_period_start_date = "%sT00:00:00Z"
recurrence_period_end_date = "%sT00:00:00Z"
file_format = "Csv"

export_data_storage_location {
container_id = azurerm_storage_container.test.resource_manager_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ resource "azurerm_billing_account_cost_management_export" "example" {
recurrence_type = "Monthly"
recurrence_period_start_date = "2020-08-18T00:00:00Z"
recurrence_period_end_date = "2020-09-18T00:00:00Z"
file_format = "Csv"

export_data_storage_location {
container_id = azurerm_storage_container.example.resource_manager_id
Expand Down Expand Up @@ -72,6 +73,8 @@ The following arguments are supported:

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

* * `file_format` - (Optional) Format for export. Valid values are `Csv` only. Default is `Csv`.

---

A `export_data_storage_location` block supports the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ resource "azurerm_resource_group_cost_management_export" "example" {
recurrence_type = "Monthly"
recurrence_period_start_date = "2020-08-18T00:00:00Z"
recurrence_period_end_date = "2020-09-18T00:00:00Z"
file_format = "Csv"

export_data_storage_location {
container_id = azurerm_storage_container.example.resource_manager_id
Expand Down Expand Up @@ -71,6 +72,8 @@ The following arguments are supported:

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

* `file_format` - (Optional) Format for export. Valid values are `Csv` only. Default is `Csv`.

---

A `export_data_storage_location` block supports the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ resource "azurerm_subscription_cost_management_export" "example" {
recurrence_type = "Monthly"
recurrence_period_start_date = "2020-08-18T00:00:00Z"
recurrence_period_end_date = "2020-09-18T00:00:00Z"
file_format = "Csv"

export_data_storage_location {
container_id = azurerm_storage_container.example.resource_manager_id
Expand Down Expand Up @@ -73,6 +74,8 @@ The following arguments are supported:

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

* `file_format` - (Optional) Format for export. Valid values are `Csv` only. Default is `Csv`.

---

A `export_data_storage_location` block supports the following:
Expand Down
Loading