Password with special characters does not work for connection block

Hi guys,

I am trying to use password through variable in the connection block of remote-exec , however, seems like its not accepting password with variable when password has special characters in it . This works fine if password has no special characters in it. This also works with special characters if I don’t use variable and directly defined i.e.

password = “mypassGJ!” >>>> working with special characters
instead of
password = var.mypass >>>>> not working with special characters

Is this the limitation with Terraform ? is there any work around available ?

Thanks in advance .

Terraform version v0.12.29
vsphere module v1.18

Following is the output during the connection:

module.vm.vsphere_virtual_machine.vm[“mytestvm1”] (remote-exec): Connecting to remote host via SSH…
module.vm.vsphere_virtual_machine.vm[“mytestvm1”] (remote-exec): Host:
module.vm.vsphere_virtual_machine.vm[“mytestvm1”] (remote-exec): User: auser
module.vm.vsphere_virtual_machine.vm[“mytestvm1”] (remote-exec): Password: true
module.vm.vsphere_virtual_machine.vm[“mytestvm1”] (remote-exec): Private key: false
module.vm.vsphere_virtual_machine.vm[“mytestvm1”] (remote-exec): Certificate: false
module.vm.vsphere_virtual_machine.vm[“mytestvm1”] (remote-exec): SSH Agent: false
module.vm.vsphere_virtual_machine.vm[“mytestvm11”] (remote-exec): Checking Host Key: false

Error: timeout - last error: SSH authentication failed (auser@ ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

Following is the remote-exec connection block :

provisioner “remote-exec” {
inline = [" echo ‘remote test’ >> /tmp/test",
" echo ‘remote test’ >> /tmp/test"]

connection {
type = “ssh”
user = “auser”
password = var.mypass
host = self.default_ip_address


The password variable is defined as follows:

variable “mypass” {
type = string
description = “Vimlog admin password”
default = “mypassGJ!”