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.64k forks source link

Support for 'node communication mode' property #20186

Open erezs80 opened 1 year ago

erezs80 commented 1 year ago

Is there an existing issue for this?

Community Note

Description

I am creating a batch pool via azurerm/azurerm_batch_pool and there's no configuration for me to change the 'node communication mode' parameter which can be Classic/Simplified/Default

Currently, when deploying pools the parameter is set by default to Classic.

New or Affected Resource(s)/Data Source(s)

azurerm_batch_pool

Potential Terraform Configuration

resource "azurerm_batch_pool" "example" {
  name                    = "testaccpool"
  resource_group_name     = azurerm_resource_group.example.name
  account_name            = azurerm_batch_account.example.name
  display_name            = "Test Acc Pool Auto"
  vm_size                 = "Standard_A1"
  node_agent_sku_id       = "batch.node.ubuntu 20.04"
  node_communication_mode = "Simplified"

  auto_scale {
    evaluation_interval = "PT15M"

    formula = <<EOF
      startingNumberOfVMs = 1;
      maxNumberofVMs = 25;
      pendingTaskSamplePercent = $PendingTasks.GetSamplePercent(180 * TimeInterval_Second);
      pendingTaskSamples = pendingTaskSamplePercent < 70 ? startingNumberOfVMs : avg($PendingTasks.GetSample(180 *   TimeInterval_Second));
      $TargetDedicatedNodes=min(maxNumberofVMs, pendingTaskSamples);
EOF

  }

  storage_image_reference {
    publisher = "microsoft-azure-batch"
    offer     = "ubuntu-server-container"
    sku       = "20-04-lts"
    version   = "latest"
  }

  container_configuration {
    type = "DockerCompatible"
    container_registries {
      registry_server = "docker.io"
      user_name       = "login"
      password        = "apassword"
    }
  }

  start_task {
    command_line       = "echo 'Hello World from $env'"
    task_retry_maximum = 1
    wait_for_success   = true

    common_environment_properties = {
      env = "TEST"
    }

    user_identity {
      auto_user {
        elevation_level = "NonAdmin"
        scope           = "Task"
      }
    }
  }

  certificate {
    id             = azurerm_batch_certificate.example.id
    store_location = "CurrentUser"
    visibility     = ["StartTask"]
  }
}

References

No response

liuwuliuyun commented 1 year ago

Hi @erezs80, thanks for raising this issue. The targetNodeCommunicationMode is not included in current batch service SDK version. To fulfill this enhancement request, we need to upgrade to latest SDK and add support for this property.

dawsonar802 commented 1 year ago

Following... This would be a great help for me as well since it looks like Simplified is the recommended mode to set. Thanks

dawsonar802 commented 1 year ago

In the mean time, has anyone been able to get the azapi_update_resource resource to work to update this? When I attempt I get the following error in response:

│ RESPONSE 400: 400 Bad Request │ ERROR CODE: InvalidIdentityValues │ -------------------------------------------------------------------------------- │ { │ "error": { │ "code": "InvalidIdentityValues", │ "message": "Invalid value for the identities '/subscriptions/<sub id>/resourceGroups/<rg name>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<id name>'. The 'UserAssignedIdentities' property keys should only be empty json objects, null or the resource exisiting property." │ } │ } │ --------------------------------------------------------------------------------

Also It looks like related to this error it was resolved awhile back, so not sure if it is something similar here or something different.

Edit I was able to work around the azapi identity error by adding a runtime flag essentially to deploy the pool first without an identity and then running the deployment again to add it back after the azapi update has completed.