'azure runbook PowerShell script content is not importing in terraform properly
I have created azure automation account using terraform. I have save my existing runbook PowerShell script files in local. I have successfully uploaded all the script files at one time while creation of automation account with below code:
resource "azurerm_automation_runbook" "example" {
for_each = fileset("Azure_Runbooks/", "*")
name = split(".", each.key)[0]
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 = file(format("%s%s", "Azure_Runbooks/", each.value)
}
However, the content of the script file is not completely uploading and getting the error like below:
Error: Too many function arguments │ │ on AutomationAccount\main.tf line 58, in resource "azurerm_automation_runbook" "example": │ 58: content = file(format("%s%s"), "Azure_Runbooks/", each.value) │ ├──────────────── │ │ each.value will be known only after apply │ │ Function "file" expects only 1 argument(s)
Can some one please help to fix above issue.
Solution 1:[1]
Below is the correct code and I have fixed the issue:
resource "azurerm_automation_runbook" "example" {
for_each = fileset("Azure_Runbooks/", "*")
name = split(".", each.key)[0]
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 = file(format("%s%s" , "Azure_Runbooks/" , each.key))
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lokesh M |
