consul-terraform-sync
consul-terraform-sync copied to clipboard
Output URL of Terraform Cloud run on create task failure
Description
If task creation fails when using the Terraform Cloud driver, the error message has the workspace name and the run ID of the failure, but not the URL to the run. A better experience would be to output a link to the run so users can easily find the details of the error. This is especially important for when the task inspection fails, as speculative runs are not listed in a workspace's run.
Example of Current Output:
$ consul-terraform-sync task create --task-file=task.hcl
==> Inspecting changes to resource if creating task 'test_task'...
Generating plan that Consul-Terraform-Sync will use Terraform to execute
==> Error: unable to generate plan for 'test_task'
400 Bad Request: unexpected run status for workspace test_task:
run-UaPbFH6VkkeWaPT5 errored, see logs for more details (Request ID:
4e470847-2ef1-eee0-12d3-1255e57fcf51)
Alternative Solutions
The run URL can be logged as part of the apply/plan or can be constructed by the CLI from the returned information:
<TFC host URL>/app/<organization>/workspaces/<workspace_name>/runs/<run_id>