Loading...
Loading...
### Is there an existing issue for this? - [X] I have searched the existing issues ### Community Note * Please vote on this issue by adding a :thumbsup: [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request * Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request * If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the [contribution guide](https://github.com/hashicorp/terraform-provider-azurerm/blob/main/contributing/README.md) to help. ### Terraform Version 1.10.0 ### AzureRM Provider Version latest ### Affected Resource(s)/Data Source(s) azurerm_virtual_machine_extension ### Terraform Configuration Files ```hcl resource "azurerm_virtual_machine_extension" "PsModulesGeneral" { count = var.mycount ? 1 : 0 name = "install_general_tools" virtual_machine_id = vmId publisher = "Microsoft.Compute" type = "CustomScriptExtension" type_handler_version = "1.9" auto_upgrade_minor_version = true protected_settings = <<PROTECTED_SETTINGS { "commandToExecute": "powershell.exe -encodedCommand ${textencodebase64(templatefile("${path.module}/myScript.ps1", var.myModules), "UTF-16LE")}" } PROTECTED_SETTINGS timeouts { create = "2h" } } ``` ### Debug Output/Panic Output ```shell │ Error: Error in function call │ │ on .terraform/path/myfile.tf line 291, in resource "azurerm_virtual_machine_extension" "PsModulesGeneral": │ 291: "commandToExecute": "powershell.exe -encodedCommand ${textencodebase64(templatefile("${path.module}/myScript.ps1", var.myModules), "UTF-16LE")}" │ ├──────────────── │ │ while calling templatefile(path, vars) │ │ path.module is ".terraform/path" │ │ var.myModules is a object │ │ Call to function "templatefile" failed: panic in function implementation: │ can't use ElementIterator on unknown value │ goroutine 7606 [running]: │ runtime/debug.Stack() │ runtime/debug/stack.go:26 +0x5e │ github.com/zclconf/go-cty/cty/function.errorForPanic(...) │ github.com/zclconf/go-cty@v1.15.1-0.20241111215639-63279be090d7/cty/function/error.go:44 │ github.com/zclconf/go-cty/cty/function.Function.Call.func2() │ github.com/zclconf/go-cty@v1.15.1-0.20241111215639-63279be090d7/cty/function/function.go:349 │ +0x9b │ panic({0x3050be0?, 0x3ddadb0?}) │ runtime/panic.go:785 +0x132 │ github.com/zclconf/go-cty/cty.Value.ElementIterator({{{0x3e20e90?, │ 0xc004dab8a0?}}, {0x315d760?, 0x5a112e0?}}) │ github.com/zclconf/go-cty@v1.15.1-0.20241111215639-63279be090d7/cty/value_ops.go:1193 │ +0xd1 │ github.com/zclconf/go-cty/cty.Value.AsValueMap({{{0x3e20e90?, │ 0xc004dab8a0?}}, {0x315d760?, 0x5a112e0?}}) │ github.com/zclconf/go-cty@v1.15.1-0.20241111215639-63279be090d7/cty/value_ops.go:1455 │ +0x99 │ github.com/hashicorp/terraform/internal/lang/funcs.MakeTemplateFileFunc.makeRenderTemplateFunc.func4({0x3e21108, │ 0xc0039cc5a0}, {{{0x3e20e90?, 0xc004dab8a0?}}, {0x315d760?, 0x5a112e0?}}) │ github.com/hashicorp/terraform/internal/lang/funcs/string.go:322 +0xea │ github.com/hashicorp/terraform/internal/lang/funcs.MakeTemplateFileFunc.func3({0xc00beb2980?, │ 0xc004dab8a0?, 0x315d760?}, {{0x3e21598?, 0x5a43160?}}) │ github.com/hashicorp/terraform/internal/lang/funcs/filesystem.go:148 +0x245 │ github.com/zclconf/go-cty/cty/function.Function.Call({0x3e20e90?}, │ {0xc00beb2980, 0x2, 0x2}) │ github.com/zclconf/go-cty@v1.15.1-0.20241111215639-63279be090d7/cty/function/function.go:353 │ +0x6bf │ github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc003df0f00, │ 0xc00a51ff68) │ github.com/hashicorp/hcl/v2@v2.23.0/hclsyntax/expression.go:528 +0x1acf │ github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc003df0ff0, │ 0xc00a51ff68) │ github.com/hashicorp/hcl/v2@v2.23.0/hclsyntax/expression.go:493 +0x1304 │ github.com/hashicorp/hcl/v2/hclsyntax.(*TemplateExpr).Value(0xc003e10a20, │ 0xc00a51ff68) │ github.com/hashicorp/hcl/v2@v2.23.0/hclsyntax/expression_template.go:36 │ +0x14d │ github.com/hashicorp/hcl/v2/hcldec.(*AttrSpec).decode(0xc009e5f140, │ 0xc00722cea8?, {0xc00542e740?, 0x19?, 0x28?}, 0xc00a51ff68) │ github.com/hashicorp/hcl/v2@v2.23.0/hcldec/spec.go:220 +0x1fc │ github.com/hashicorp/hcl/v2/hcldec.ObjectSpec.decode(0xc009e5f0e0, │ 0xc003993e00, {0x0, 0x0, 0x0}, 0xc00a51ff68) │ github.com/hashicorp/hcl/v2@v2.23.0/hcldec/spec.go:94 +0x1f8 │ github.com/hashicorp/hcl/v2/hcldec.decode({0x3e22ad0, 0xc008c65dc0}, {0x0, │ 0x0, 0x0}, 0xc00a51ff68, {0x3e21618, 0xc009e5f0e0}, 0x0) │ github.com/hashicorp/hcl/v2@v2.23.0/hcldec/decode.go:24 +0x10f │ github.com/hashicorp/hcl/v2/hcldec.Decode(...) │ github.com/hashicorp/hcl/v2@v2.23.0/hcldec/public.go:18 │ github.com/hashicorp/terraform/internal/lang.(*Scope).EvalBlock(0xc0095b2c60, │ {0x3e21060, 0xc009679bd0}, 0xc008875bf0) │ github.com/hashicorp/terraform/internal/lang/eval.go:75 +0x207 │ github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateBlock(0xc005a85530?, │ {0x3e21390, 0xc003e838c0}, 0xc008875bf0, {0x0?, 0x0?}, {{{{0x3e20b18, │ 0xc000013bf8}}, {0x315d760, 0x5a112e0}}, ...}) │ github.com/hashicorp/terraform/internal/terraform/eval_context_builtin.go:324 │ +0x145 │ github.com/hashicorp/terraform/internal/terraform.(*NodeValidatableResource).validateResource(0xc005da0458, │ {0x3e48bb8, 0xc0065f7300}) │ github.com/hashicorp/terraform/internal/terraform/node_resource_validate.go:348 │ +0x726 github.com/hashicorp/terraform/internal/terraform.(*NodeValidatableResource).Execute(0xc005da0458, │ {0x3e48bb8, 0xc0065f7300}, 0x0?) │ github.com/hashicorp/terraform/internal/terraform/node_resource_validate.go:56 │ +0xb8 │ github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc005ffe6e0, │ {0x3e48bb8, 0xc0065f7300}, {0x7f6f24e2eb70, 0xc005da0458}) │ github.com/hashicorp/terraform/internal/terraform/graph_walk_context.go:161 │ +0xb5 │ github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x36b4c40, │ 0xc005da0458}) │ github.com/hashicorp/terraform/internal/terraform/graph.go:143 +0x7c3 │ github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc002a7a840, │ {0x36b4c40, 0xc005da0458}, 0xc00ab63680) │ github.com/hashicorp/terraform/internal/dag/walk.go:384 +0x2d1 │ created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update in │ goroutine 19 │ github.com/hashicorp/terraform/internal/dag/walk.go:307 +0xfb3 │ . ╵ Failed: Error while executing terraform plan. ``` ### Expected Behaviour This should work as it did in 1.9.8 ### Actual Behaviour Using 1.10.0 with the same TF files, the plan fails immediately. ### Steps to Reproduce _No response_ ### Important Factoids _No response_ ### References _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.