Skip to content

Commit

Permalink
azurerm_log_analytics_workspace - Support rentention_in_days for …
Browse files Browse the repository at this point in the history
…Free Tier (#6844)
  • Loading branch information
magodo committed May 12, 2020
1 parent 796f2d0 commit a99bfcb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
Expand Up @@ -69,7 +69,7 @@ func resourceArmLogAnalyticsWorkspace() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(30, 730),
ValidateFunc: validation.Any(validation.IntBetween(30, 730), validation.IntInSlice([]int{7})),
},

"workspace_id": {
Expand Down
Expand Up @@ -115,6 +115,25 @@ func TestAccAzureRMLogAnalyticsWorkspace_complete(t *testing.T) {
})
}

func TestAccAzureRMLogAnalyticsWorkspace_freeTier(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_log_analytics_workspace", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMLogAnalyticsWorkspaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLogAnalyticsWorkspace_freeTier(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLogAnalyticsWorkspaceExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func testCheckAzureRMLogAnalyticsWorkspaceDestroy(s *terraform.State) error {
conn := acceptance.AzureProvider.Meta().(*clients.Client).LogAnalytics.WorkspacesClient
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
Expand Down Expand Up @@ -229,3 +248,24 @@ resource "azurerm_log_analytics_workspace" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func testAccAzureRMLogAnalyticsWorkspace_freeTier(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_log_analytics_workspace" "test" {
name = "acctestLAW-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Free"
retention_in_days = 7
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}
2 changes: 1 addition & 1 deletion website/docs/r/log_analytics_workspace.html.markdown
Expand Up @@ -41,7 +41,7 @@ The following arguments are supported:

~> **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 SKU's defined above. More information about [the Pricing SKU's is available at the following URI](http://aka.ms/PricingTierWarning).

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

* `tags` - (Optional) A mapping of tags to assign to the resource.

Expand Down

0 comments on commit a99bfcb

Please sign in to comment.