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_log_analytics_workspace - Support rentention_in_days for Free Tier #6844

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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