面对错误的Terraform代码,用于将多本运行本导入Azure Automation帐户
我使用Terraform代码创建了Azure自动化帐户。我有多个Runbooks Powershell脚本保存在我的本地中。我正在使用for.east选项一次导入所有运行簿。但是在运行Terraform文件时,我会遇到一些错误。请在下面找到我的代码:
resource "azurerm_automation_runbook" "example" {
for_each = fileset(".", "./Azure_Runbooks/*.ps1")
name = ["${split("/", each.value)}"][1]
location = var.location
resource_group_name = var.resource_group
automation_account_name = azurerm_automation_account.example.name
log_verbose = var.log_verbose
log_progress = var.log_progress
runbook_type = var.runbooktype
content = filemd5("${each.value}")
}
Error:
Error: Invalid index
│
│ on AutomationAccount\main.tf line 51, in resource "azurerm_automation_runbook" "example":
│ 51: name = ["${split("/", each.value)}"][1]
│ ├────────────────
│ │ each.value will be known only after apply
│
│ The given key does not identify an element in this collection value: the given index is greater than
│ or equal to the length of the collection.
有人可以帮助我如何使用Terraform代码上传所有现有的Runbook scrips到新创建的自动化帐户。
I have created the azure automation account using terraform code. I have multiple runbooks PowerShell scripts saved in my local. I am using for.each option to import all the runbooks at a time. But I am getting some errors while running the terraform file. Please find my code below:
resource "azurerm_automation_runbook" "example" {
for_each = fileset(".", "./Azure_Runbooks/*.ps1")
name = ["${split("/", each.value)}"][1]
location = var.location
resource_group_name = var.resource_group
automation_account_name = azurerm_automation_account.example.name
log_verbose = var.log_verbose
log_progress = var.log_progress
runbook_type = var.runbooktype
content = filemd5("${each.value}")
}
Error:
Error: Invalid index
│
│ on AutomationAccount\main.tf line 51, in resource "azurerm_automation_runbook" "example":
│ 51: name = ["${split("/", each.value)}"][1]
│ ├────────────────
│ │ each.value will be known only after apply
│
│ The given key does not identify an element in this collection value: the given index is greater than
│ or equal to the length of the collection.
Can someone please help how I can upload all my existing runbook scrips to the newly created automation account using terraform code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要列表中的列表。所以
应该不是
You don't need list in a list. So instead of
it should be