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.53k stars 4.6k forks source link

azurerm_netapp_volume creation issue due to storage_quota-in_gb parameter not working as intended in the provider #16210

Open sagarhatrote1 opened 2 years ago

sagarhatrote1 commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

v1.1.7

AzureRM Provider Version

3.0.2

Affected Resource(s)/Data Source(s)

azurerm_netapp_volume

Terraform Configuration Files

Terraform v1.1.7
on windows_386
+ provider registry.terraform.io/hashicorp/azurerm v2.96.0

Debug Output/Panic Output

Error: creating Volume: (Name "testanf" / Capacity Pool Name "test1" / Net App Account Name "MyNaas_ANF_GWC" / Resource Group "sandbox"): netapp.VolumesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidValueReceived" Message="An invalid value '0' was received for Volume.UsageThreshold. Must be 100 gibibytes in bytes or higher"

Expected Behaviour

the volume of 200gb should have been created as the tfvar says

Actual Behaviour

getting the error mentioned below

Error: creating Volume: (Name "testanf" / Capacity Pool Name "test1" / Net App Account Name "MyNaas_ANF_GWC" / Resource Group "sandbox"): netapp.VolumesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidValueReceived" Message="An invalid value '0' was received for Volume.UsageThreshold. Must be 100 gibibytes in bytes or higher"

Steps to Reproduce

Tools to be used

visual studio code terraform version 1.1.17 run the volume creation code from link mentioned below https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/netapp_volume

Important Factoids

no

References

not applicable

xiaxyi commented 2 years ago

@sagarhatrote1 according to the des, you are setting the property storage_quota_in_gb to 200 then hit below error:

Error: creating Volume: (Name "testanf" / Capacity Pool Name "test1" / Net App Account Name "MyNaas_ANF_GWC" / Resource Group "sandbox"): netapp.VolumesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidValueReceived" Message="An invalid value '0' was received for Volume.UsageThreshold. Must be 100 gibibytes in bytes or higher"

I tried to reproduce the issue but unfortunately, I can't get the error and the volume can be created as expected. below is my test script

provider "azurerm" {
  features {}
}
terraform{
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=2.96.0"
    }
  }
}
resource "azurerm_resource_group" "example" {
  name     = "xiaxintestrg-netapp"
  location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
  name                = "xiaxin-virtualnetwork"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "example" {
  name                 = "xiaxin-subnet"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.2.0/24"]

  delegation {
    name = "netapp"

    service_delegation {
      name    = "Microsoft.Netapp/volumes"
      actions = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"]
    }
  }
}

resource "azurerm_netapp_account" "example" {
  name                = "xiaxin-netappaccount"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_netapp_pool" "example" {
  name                = "xiaxin-netapppool"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  account_name        = azurerm_netapp_account.example.name
  service_level       = "Premium"
  size_in_tb          = 4
}

resource "azurerm_netapp_volume" "example" {
  lifecycle {
    prevent_destroy = true
  }

  name                       = "xiaxin-netappvolume"
  location                   = azurerm_resource_group.example.location
  resource_group_name        = azurerm_resource_group.example.name
  account_name               = azurerm_netapp_account.example.name
  pool_name                  = azurerm_netapp_pool.example.name
  volume_path                = "my-unique-file-path"
  service_level              = "Premium"
  subnet_id                  = azurerm_subnet.example.id
  protocols                  = ["NFSv4.1"]
  security_style             = "Unix"
  storage_quota_in_gb        = 200
  snapshot_directory_visible = false
  export_policy_rule {
    rule_index        = 1
    allowed_clients   = ["1.2.3.0/24"]
    protocols_enabled = ["NFSv4.1"]
    unix_read_only    = false
    unix_read_write   = true
  }
}

can you share the full script that you used?

veeraragavan52jtb commented 2 years ago

Hello @xiaxyi & @sagarhatrote1

We do have similar issue, we tried with 100 GB and its failed. Please let us know if we have any workaround can be tried.

Looks like it is working randomly.

Error reported:

"statusMessage": "{\"error\":{\"code\":\"InvalidValueReceived\",\"message\":\"An invalid value '0' was received for Volume.UsageThreshold. Must be 100 gibibytes in bytes or higher\"}}",

    "eventCategory": "Administrative",

    "entity": "/subscriptions/b31dfb80-46e0-4f61-848e-c7344b5e546a/resourceGroups/RG-UBS-TF/providers/Microsoft.NetApp/netAppAccounts/netappaccount/capacityPools/mypool1/volumes/myvol1"

Terraform & Azure RM version are latest.

@BrightJames for visibility

BrightJames commented 2 years ago

I have tried using 100 GB and 200 GB Volume. same error getting.

Followed: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/netapp_volume

image

image

image

==================================================

terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "3.17.0" } } }

Configure the Microsoft Azure Provider

provider "azurerm" { features {} }

resource "azurerm_resource_group" "example" { name = "RG-UBS-TF" location = "westus2" tags = { Environment = "FileShare" Team = "UBS" } }

resource "azurerm_virtual_network" "example" { name = "UBS-VNet" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name address_space = ["10.6.0.0/16"] dns_servers = ["10.6.0.4"] tags = { environment = "ANF VNet" } }

resource "azurerm_subnet" "example" { name = "ANF-Subnet" resource_group_name = azurerm_resource_group.example.name virtual_network_name = azurerm_virtual_network.example.name address_prefixes = ["10.6.0.0/26"]

delegation { name = "Microsoft.Netapp/volumes"

service_delegation {
  name    = "Microsoft.Netapp/volumes"
  actions = ["Microsoft.Network/virtualNetworks/subnets/join/action", "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action"]
}

} }

resource "azurerm_netapp_account" "example" { name = "netappaccount" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name }

resource "azurerm_netapp_pool" "example" { name = "mypool1" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name account_name = azurerm_netapp_account.example.name service_level = "Premium" size_in_tb = 4 }

resource "azurerm_netapp_volume" "example" { lifecycle { prevent_destroy = true } name = "myvol1" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name account_name = azurerm_netapp_account.example.name pool_name = azurerm_netapp_pool.example.name volume_path = "my-unique-file-path" service_level = "Premium" subnet_id = azurerm_subnet.example.id protocols = ["NFSv4.1"] security_style = "Unix" storage_quota_in_gb = 300

export_policy_rule { rule_index = 1 allowed_clients = ["10.6.0.0/26"] protocols_enabled = ["NFSv4.1"] unix_read_only = false unix_read_write = true } }

===================================

BrightJames commented 2 years ago

Any update ?

amr1166 commented 2 years ago

Hi @BrightJames. I had the same issue #17914 and It is resolved by updating Terraform to 64 bit(windows_amd64) version. Initially I was using terraform windows_386(32 bit) version and which was unable to take the 100gb value for Volume.UsageThreshold. Since I am using 64bit Operating system, I have updated the terraform version to 64 bit as well.