Terraform escape special char

terraform

I have to pass a password through terraform which has special characters including backslash.

Terraform apply resulted in following error

27: "project.plugin.NodeExecutor.WinRMexe.pass" = "j7FUBa&:9"

The symbol ":" is not a valid escape sequence selector.

Best Answer

You need to declare your variable as string, I am using terraform 0.12 and I did as follow.

vars.tf:

variable "test" {
  type = string
  default = "j7FUBa&:9"
}

output.tf

output "mytest" {
  value = var.test
}

Now you could see the result using terraform apply:

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

mytest = j7FUBa&:9
Related Topic