Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Can't access vars in resource_configuration #104

@g1ps

Description

@g1ps

vRA 7.x version
Version: 7.5.0 (Build: 10053500)

Terraform version
Terraform v0.14.4

terraform-provider-vra7 plugin version

  • provider registry.terraform.io/vmware/vra7 v3.0.0

Describe the bug

Variables inside resource_configuration blocks are inaccessible.

Hello,

After huge gobs of pain I had deployment working under Terraform 11. I have just been through the various upgrade steps to move to V14 but I am now unable to access vars in resource_configuration. I've spent a day and a half searching and trying things I've found here and elsewhere without any real progress. Terraform complains Error: Invalid template interpolation value: Cannot include the given value in a string template: string required. after the VM is deployed successfully and stops.

I've seen that this problem has been experienced by others. I've tried things with and without count but I really want it to remain to permit mutilple deployments. My script looks in part like this:

...
output "ansible-master-IP-address" {
  value = vra7_deployment.ansible_master[*].resource_configuration[*].instances[*].properties.ip_address
}

output "ansible-master-name" {
  value = vra7_deployment.ansible_master[*].resource_configuration[*].instances[*].properties.name
}

provider "vra7" {
  username = var.vra_user
  password = var.vra_password
  tenant   = "XXXXXXX"
  host     = "https://secret.com/"
  insecure = false
}

resource "vra7_deployment" "ansible_master" {
  businessgroup_name = "dev"
  catalog_item_name  = "Red Hat Enterprise Linux 8"
  count              = 1
  description        = "Ansible master."
  reasons            = "Automation"
  wait_timeout       = 30
  lease_days         = 390

  resource_configuration {
    component_name = "RHEL8"
    configuration = {
      cpu         = "1"
      memory      = "4096"
      description = "Ansible master"
      ip_address  = ""
      name        = ""
    }
  }

  deployment_configuration = {
    _number_of_instances = 1
  }

  # Copy the files.
  provisioner "file" {
    source      = "ansible/"
    destination = "./"

    connection {
      type     = "ssh"
      host     = "${self.resource_configuration[*].instances[*].properties.name}.domain.com"
      user     = var.vra_user
      password = var.vra_password
    }
  }

...

I've tried splats, as seen in the output vars. I've tried self as seen in the file provisioner connection block. I've tried with and without properties and instances and many other things and I still can't get this to run. vra7_deployment.ansible_master[*] in connection also fails. Can someone help, please, as this really does seem like a bug rather than a 'feature' and no amount of trying will make it work here? It shouldn't be this hard especially given that it worked previously.

Thanks.

To Reproduce
As described above. Even paths which work from terraform console do not work in production.

Expected behavior
Variables inside resource_configuration should be accessible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions