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

Error: Incorrect attribute value type: Inappropriate value for attribute "host": string required. #65

Open
hobovirtual opened this issue Apr 27, 2020 · 2 comments

Comments

@hobovirtual
Copy link

hobovirtual commented Apr 27, 2020

vRA 7.x version
vRealize Automation 7.6

Terraform version
v0.12.24

terraform-provider-vra7 plugin version
terraform-provider-vra7 plugin version 1.0.1

Describe the bug
Trying to use the remote_exec provisioner to execute commands post installation. When we use the examples provided in the documentation we get an error.

To Reproduce
Steps to reproduce the behavior:

  1. define the following in any maint.tf
  connection {
    host     = self.resource_configuration[*].ip_address
    user     = var.upn_username
    password = var.domain_password
    type     = "ssh"
  }
 
  provisioner "remote-exec" {
    inline = [
      "echo hello"
    ]
  }
  1. Terraform command
    terraform apply

  2. Error
    Error: Incorrect attribute value type: Inappropriate value for attribute "host":
    string required.

Expected behavior
remote command to be executed on the target

Desktop (please complete the following information):

  • OS: Windows 2016 and CentOS 7

Extra Information
If i remove the block above and just output the information the information is displayed as expected but in an array and not a single string

output "vm_name" {
  value = ["${vra7_deployment.deployment[*].resource_configuration[*].name}"]
}
 
output "vm_ip" {
  value = ["${vra7_deployment.deployment[*].resource_configuration[*].ip_address}"]
}

The issue appears to be related to the self object and the way the data is return from the data map from the provider!?

@hobovirtual
Copy link
Author

hobovirtual commented Apr 27, 2020

Update

I was able to do a remote_exec using this block

connection {
    host     = element(self.resource_configuration[*].ip_address, 0)
    user     = var.upn_username
    password = var.domain_password
    type     = "ssh"
  }
 
  provisioner "remote-exec" {
    inline = [
      "echo hello"
    ]
  }

Need to do more testing but so far so good

@Prativa20 is this the expected behavior? If so should we update the documentation to reflect this?

@Prativa20
Copy link
Contributor

Yes @hobovirtual, we should update the documentation. Thanks for looking into it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants