Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra_config: doesn't work with dynamic blocks #2156

Open
4 tasks done
iBrandyJackson opened this issue Mar 14, 2024 · 0 comments
Open
4 tasks done

extra_config: doesn't work with dynamic blocks #2156

iBrandyJackson opened this issue Mar 14, 2024 · 0 comments
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Milestone

Comments

@iBrandyJackson
Copy link
Member

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

v1.7.1

Terraform Provider

v2.6.1

VMware vSphere

v7

Description

The extra_config block doesn't work with Dynamic Block expression. Using for_each under dynamic "extra_config" is not working as expected. This prevents customers from dynamically setting extra_config values to VMs.

Affected Resources or Data Sources

vsphere_virtual_machine

Terraform Configuration

The code block is like this:

dynamic "extra_config" {
    for_each = var.is_windows_image ? [] : [1]
    content = {
      "guestinfo.metadata" = base64encode(templatefile("${path.module}/scripts/metadata.yaml", {
        name           = each.value.name,
        ipv4_address_1 = infoblox_a_record.infoblox_network1[each.key].ip_addr,
        ipv4_address_2 = length(infoblox_a_record.infoblox_network2) > 0 ? infoblox_a_record.infoblox_network2[each.key].ip_addr : "",
        ipv4_gateway   = var.ipv4_gateway_network1,
        vm_domain      = var.domain,
        dns_server_1   = var.dns_server_1
      }))
      "guestinfo.metadata.encoding" = "base64"
      "guestinfo.userdata" = base64encode(templatefile("${path.module}/scripts/userdata.yaml", {
        domain         = var.domain,
        ipv4_address_1 = infoblox_a_record.infoblox_network1[each.key].ip_addr,
        name           = each.value.name,
        role           = each.value.role,
        instance_role  = each.value.instance_role == null ? "role.${each.value.role}_deploy" : each.value.instance_role
      }))
      "guestinfo.userdata.encoding" = "base64"
    }
  }

Debug Output

n/a

Panic Output

No response

Expected Behavior

terraform plan should be executed successfully

Actual Behavior

When using the resource vsphere_virtual_machine and setting extra_config as a dynamic block. When configuring for_each = var.is_windows_image ? [] : [1}}] with a {{content block, it errors out with Error: Unsupported block type after executing a terraform plan. Error outputs:

│ Error: Unsupported block type
│ 
│   on ../../modules/vsphere/main.tf line 84, in resource "vsphere_virtual_machine" "vm":
│   84:   dynamic "extra_config" {
│ 
│ Blocks of type "extra_config" are not expected here.

Steps to Reproduce

using the resource vsphere_virtual_machine and set extra_config as a dynamic block.

Environment Details

No response

Screenshots

No response

References

#GH-1346

@iBrandyJackson iBrandyJackson added bug Type: Bug needs-triage Status: Issue Needs Triage labels Mar 14, 2024
@tenthirtyam tenthirtyam added this to the Backlog milestone Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Projects
None yet
Development

No branches or pull requests

2 participants