hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.65k forks source link

Event Hub Namespace: Cannot disable auto_inflate when max_throughput_units is set #25786

Open l33tCod-er opened 6 months ago

l33tCod-er commented 6 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.7.2

AzureRM Provider Version

3.92.0

Affected Resource(s)/Data Source(s)

azurerm_eventhub_namespace

Terraform Configuration Files

First run, create resource with auto_inflate disabled and max_throughput_units set to a static value

resource "azurerm_eventhub_namespace" "eventhub_namespace" {
  name                     = "<name>"
  location                 = "<location>"
  resource_group_name      = "<resource_group>"
  sku                      = "<sku>"
  capacity                 = "<capacity>"
  auto_inflate_enabled     = false
  maximum_throughput_units = 5  
}

Second run, enable auto_infate through:
resource "azurerm_eventhub_namespace" "eventhub_namespace" {
  name                     = "<name>"
  location                 = "<location>"
  resource_group_name      = "<resource_group>"
  sku                      = "<sku>"
  capacity                 = "<capacity>"
  auto_inflate_enabled     = true
  maximum_throughput_units = 0 #must be zero when auto_inflate_enabled is true  
}

Debug Output/Panic Output

Plan output, relevant part only: 

# azurerm_eventhub_namespace.eventhub_namespace will be updated in-place
  ~ resource "azurerm_eventhub_namespace" "eventhub_namespace" {
      ~ auto_inflate_enabled                = true -> false
      ~ maximum_throughput_units            = 5 -> 0
  }

Apply: 
Unexpected status 400 with error: CannotSetMaxThroughputValue: Maximum throughput units cannot be greater than 0 if auto inflate is false.

Expected Behaviour

Auto inflate is disabled

Actual Behaviour

Unexpected status 400 with error: CannotSetMaxThroughputValue: Maximum throughput units cannot be greater than 0 if auto inflate is false.

Steps to Reproduce

  1. Create event hub namespace with "auto_inflate" disabled and a static setting of maximum_throughput_units
  2. Disable auto_inflate and set "0" to maximum_throughput_units

Note: Leaving maximum_throughput_units to its original value does not help

Important Factoids

No response

References

No response

xiaxyi commented 6 months ago

Thanks @l33tCod-er for raising this issue, the api doesn't allow the maximum_throughput_units be set to a value that's greater than 0. You should get the error in your first step.

First run, create resource with auto_inflate disabled and max_throughput_units set to a static value

resource "azurerm_eventhub_namespace" "eventhub_namespace" {
  name                     = "<name>"
  location                 = "<location>"
  resource_group_name      = "<resource_group>"
  sku                      = "<sku>"
  capacity                 = "<capacity>"
  auto_inflate_enabled     = false
  maximum_throughput_units = 5  
}

image

l33tCod-er commented 6 months ago

Hi @xiaxyi! Thanks for your answer! I made a mistake describing the issue.

On first run, it should be: auto_inflate_enabled = true maximum_thrughput_units = 5

And the second run tried to disable again through: auto_inflate_enabled = false maximum_thrughput_units = 0

That way, it fails on second run with the 400 error as stated.

WTSParadigm commented 5 months ago

I had the same problem. I wonder if it was a change on the azure side because I had numerous successful builds where the setting was false (we weren't setting maximum_throughput_units but that had a value of 3 on our namespace) As a workaround, so I could still apply my terraform I went to the portal, manually set auto-inflate to true and saved, then set auto-inflate to false.

dtheodor commented 1 day ago

Having the same issue. It is impossible to "downgrade" an eventhub to no inflate after it has been set to auto inflate. Getting a plan of

  # azurerm_eventhub_namespace.hub will be updated in-place
  ~ resource "azurerm_eventhub_namespace" "hub" {
      ~ auto_inflate_enabled                      = true -> false
      - maximum_throughput_units                  = 4 -> 0
    }

and a plan execution error of

unexpected status 400 (400 Bad Request) with error: CannotSetMaxThroughputValue: Maximum throughput units cannot be greater than 0 if auto inflate is false.