Terraform-provider-azurerm: AzureRM azurerm_log_analytics_workspace fails when retention_in_days is set

Created on 26 Feb 2019  ·  8Comments  ·  Source: terraform-providers/terraform-provider-azurerm

When attempting to create a log analytics workspace with the retention_in_days set, the request fails with the following error:

* azurerm_log_analytics_workspace.workspace: operationalinsights.WorkspacesClient#CreateOrUpdate: Failure sending request: StatusC
ode=400 -- Original Error: Code="BadRequest" Message="The value provided for retention is invalid" Target="retention"

If I remove the parameter the resource is created with no issues.
When I run terraform plan I get the expected change listed: retention_in_days: "7" => "30" and if the number of retention days is below 30 I even get a validation failed message back.

I create the resource in the following way:

resource "azurerm_log_analytics_workspace" "workspace" {
  name                = "${var.name}"
  location            = "${var.location}"
  resource_group_name = "${var.resource_group_name}"
  sku                 = "${var.sku}"
  retention_in_days   = 30
}

I use version 1.22.1 of the AzureRM provider and Terraform version 0.11.11.

Am I doing something wrong? I believe I'm doing exactly as the examples found in source code and documentation suggest.

question servicoms

All 8 comments

This only accepts values between 30 & 730 so you will get an error when the value is below this:

https://www.terraform.io/docs/providers/azurerm/r/log_analytics_workspace.html#retention_in_days

I am aware of this. I thought it was clear from my question that I did try within the allowed range. When I try with a smaller number I get a validation error as expected (just a sign that nothing is wrong with the request).
When I leave out the parameter it creates the resource with 7 as the number of retention days.

Are you using the Free tier?

Yes, I am using the free tier. I tried using the PerGB2018 used in various examples, but with that I'm getting the following error message:

* azurerm_log_analytics_workspace.workspace: operationalinsights.WorkspacesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="Pricing tier doesn't match the subscription's billing model. Read http://aka.ms/PricingTierWarning for more details."

I am not aware what my subscriptions billing model is.

Free Tier only allows 7 days retention

Oh, I bet that's the issue then. Gotta find a SKU code that works for my subscription. I'll see what I can find tomorrow and test it.
Thanks a lot.

That was the issue. Thank you!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings