Terraform:如何将库中的 PS 个模块安装到 Azure 自动化中?

Terraform: How to install PS Modules from Gallery into Azure Automation?

如何使用 Terraform 将库中的 PowerShel 模块安装到我的 Azure 自动化帐户中?

我尝试使用 powershellgallery API url:

resource "azurerm_automation_account" "aac" {
  name                = var.azure_automation_account_name
  location            = var.location
  tags                = var.tags
  resource_group_name = var.resource_group
  sku_name = "Basic"
}

resource "azurerm_automation_module" "az_accounts" {
  name                    = "az_accounts"
  resource_group_name     = var.resource_group
  automation_account_name = azurerm_automation_account.aac.name

  module_link {
    uri = "https://www.powershellgallery.com/api/v2/package/az.accounts/2.2.4"
  }
}

这总是让我出错(我尝试了几个不同版本的模块,没有任何区别):

Error: Error waiting for Module "az_accounts" (Automation Account "XXX" / Resource Group "YYY") to finish provisioning: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: Cannot import the module of name az_accounts, as the module structure was invalid.

我做错了什么?

一月

模块名称应为"Az.Accounts"。这对我有用。

resource "azurerm_automation_module" "example" {
  name                    = "Az.Accounts"
  resource_group_name     = azurerm_resource_group.example.name
  automation_account_name = azurerm_automation_account.example.name

  module_link {
    uri = "https://www.powershellgallery.com/api/v2/package/az.accounts/2.2.4"
  }
}