how can I install a PowerShel module from the Gallery into my azure Automation Account using Terraform?
I tried using 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"
}
}
This allways gets me an error (I tried several modules with different versions, made no difference):
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.
What am I doing wrong here?
Jan
The module name should be "Az.Accounts"
. This works for me.
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"
}
}