hashicorp / hashicorp/terraform-exec

tfexec `Terraform.Output` method returns error when command is successful

Open
#470 2 comments 0 reactions 1 assignee Claimed by @kmoe View on GitHub
Dominant language
Go
Stars
786
Forks
129
PR merge metrics
No merged PRs in 30d

Description

I am using terraform-exec with HCP terraform to manage some infra. When running `terraform output` command, logs show that there was a connection error and it's trying to re-establish the connection, eventually the command logs the correct output, but `Terraform.Output` method returns an error.

Expected behaviour: error returned by `Terraform.Output` should be nil.

Error returned by the library:
`invalid character 'T' looking for beginning of value`

Logs:
```
time=2024-07-11T13:06:33.111Z level=INFO msg="[INFO] running Terraform command: /home/terraform/app/terraform output -no-color -json"

There was an error connecting to HCP Terraform. Please do not exit
Terraform to prevent data loss! Trying to restore the connection...

Still trying to restore the connection... (3s elapsed)
Still trying to restore the connection... (5s elapsed)
Still trying to restore the connection... (8s elapsed)
Still trying to restore the connection... (12s elapsed)
Still trying to restore the connection... (17s elapsed)
{
"ubuntu1_public_dns": {
"sensitive": false,
"type": "string",
"value": ""
},
"ubuntu_public_dns": {
"sensitive": false,
"type": "string",
"value": ""
}
}
```

It's probably failing when trying to convert the command's output into `map[string]OutputMeta`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.