Skip to content

Commit

Permalink
fix: adjust doc and code to support sku free tier is no longer available
Browse files Browse the repository at this point in the history
  • Loading branch information
hqhqhqhqhqhqhqhqhqhqhq committed Jun 27, 2024
1 parent 8f6ec5c commit 1a482d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 17 additions & 2 deletions internal/services/loganalytics/log_analytics_workspace_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/loganalytics/migration"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/loganalytics/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
Expand All @@ -31,7 +32,7 @@ import (
)

func resourceLogAnalyticsWorkspace() *pluginsdk.Resource {
return &pluginsdk.Resource{
schema := &pluginsdk.Resource{
Create: resourceLogAnalyticsWorkspaceCreateUpdate,
Read: resourceLogAnalyticsWorkspaceRead,
Update: resourceLogAnalyticsWorkspaceCreateUpdate,
Expand Down Expand Up @@ -107,7 +108,6 @@ func resourceLogAnalyticsWorkspace() *pluginsdk.Resource {
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(workspaces.WorkspaceSkuNameEnumFree),
string(workspaces.WorkspaceSkuNameEnumPerGBTwoZeroOneEight),
string(workspaces.WorkspaceSkuNameEnumPerNode),
string(workspaces.WorkspaceSkuNameEnumPremium),
Expand Down Expand Up @@ -179,6 +179,21 @@ func resourceLogAnalyticsWorkspace() *pluginsdk.Resource {
"tags": commonschema.Tags(),
},
}

if !features.FourPointOh() {
schema.Schema["sku"].ValidateFunc = validation.StringInSlice([]string{
string(workspaces.WorkspaceSkuNameEnumFree),
string(workspaces.WorkspaceSkuNameEnumPerGBTwoZeroOneEight),
string(workspaces.WorkspaceSkuNameEnumPerNode),
string(workspaces.WorkspaceSkuNameEnumPremium),
string(workspaces.WorkspaceSkuNameEnumStandalone),
string(workspaces.WorkspaceSkuNameEnumStandard),
string(workspaces.WorkspaceSkuNameEnumCapacityReservation),
"Unlimited", // TODO check if this is actually no longer valid, removed in v28.0.0 of the SDK
}, false)
}

return schema
}

func resourceLogAnalyticsWorkspaceCustomDiff(ctx context.Context, d *pluginsdk.ResourceDiff, _ interface{}) error {
Expand Down
4 changes: 1 addition & 3 deletions website/docs/r/log_analytics_workspace.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ The following arguments are supported:

* `local_authentication_disabled` - (Optional) Specifies if the log Analytics workspace should enforce authentication using Azure AD. Defaults to `false`.

* `sku` - (Optional) Specifies the SKU of the Log Analytics Workspace. Possible values are `Free`, `PerNode`, `Premium`, `Standard`, `Standalone`, `Unlimited`, `CapacityReservation`, and `PerGB2018` (new SKU as of `2018-04-03`). Defaults to `PerGB2018`.
* `sku` - (Optional) Specifies the SKU of the Log Analytics Workspace. Possible values are `PerNode`, `Premium`, `Standard`, `Standalone`, `Unlimited`, `CapacityReservation`, and `PerGB2018` (new SKU as of `2018-04-03`). Defaults to `PerGB2018`.

~> **NOTE:** A new pricing model took effect on `2018-04-03`, which requires the SKU `PerGB2018`. If you're provisioned resources before this date you have the option of remaining with the previous Pricing SKU and using the other SKUs defined above. More information about [the Pricing SKUs is available at the following URI](https://aka.ms/PricingTierWarning).

~> **NOTE:** Changing `sku` forces a new Log Analytics Workspace to be created, except when changing between `PerGB2018` and `CapacityReservation`. However, changing `sku` to `CapacityReservation` or changing `reservation_capacity_in_gb_per_day` to a higher tier will lead to a 31-days commitment period, during which the SKU cannot be changed to a lower one. Please refer to [official documentation](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/cost-logs#commitment-tiers) for further information.

~> **NOTE:** The `Free` SKU has a default `daily_quota_gb` value of `0.5` (GB).

* `retention_in_days` - (Optional) The workspace data retention in days. Possible values are either 7 (Free Tier only) or range between 30 and 730.

* `daily_quota_gb` - (Optional) The workspace daily quota for ingestion in GB. Defaults to -1 (unlimited) if omitted.
Expand Down

0 comments on commit 1a482d4

Please sign in to comment.