使用 Terraform 导入 Azure 自动化 runbook

Import Azure Automation runbook using Terraform

谁能帮我问一下:我想使用 Terraform 从 runbook 库中导入 azure 自动化帐户中的 runbook。在下面的示例中,我指的是一个 URI,但我想从 Runbook 库中导入:

  resource "azurerm_automation_runbook" "example" {
  name                = "Get-AzureVMTutorial"
  location            = "${azurerm_resource_group.example.location}"
  resource_group_name = "${azurerm_resource_group.example.name}"
  account_name        = "${azurerm_automation_account.example.name}"
  log_verbose         = "true"
  log_progress        = "true"
  description         = "This is an example runbook"
  runbook_type        = "PowerShellWorkflow"
  publish_content_link {
  uri = "${var.runbooklink}"
  }
  }`

在门户中

自动化帐户 -> Runbook -> 浏览库 -> Select 您要导入的 Runbook -> 查看源项目

复制url

查看源项目将重定向到该特定 Runbook 的 URI(gallery.technet.microsoft.com 中的源代码)

对于上面的图像(例如 azure runbook 的 hello world),它将 URI 重定向到我

https://gallery.technet.microsoft.com/scriptcenter/The-Hello-World-of-Windows-81b69574/file/111354/1/Write-HelloWorld.ps1

只需尝试将其粘贴到您的代码中 (uri = "${var.runbooklink}")

resource "azurerm_automation_runbook" "demorunbook" {
  name                = "Write-HelloWorld"
  location            = "${azurerm_resource_group.development1.location}"
  resource_group_name = "${azurerm_resource_group.development1.name}"
  account_name        = "automationAccount1"
  log_verbose         = "true"
  log_progress        = "true"
  description         = "This is an example runbook"
  runbook_type        = "PowerShellWorkflow"
  publish_content_link {
  uri = "https://gallery.technet.microsoft.com/scriptcenter/The-Hello-World-of-Windows-81b69574/file/111354/1/Write-HelloWorld.ps1"
  }
  }

注意源代码中runbook的名字应该是你的runbook的名字