Open lornasong opened 2 years ago
Confirmed that this is also happening in v0.3.0-ent
and also with the output of running inspect mode.
It looks like Terraform Cloud behavior differs based on the Terraform CLI version for the workspace. The output changes between Terraform 0.15.1
and 0.15.2
.
task {
name = "kngo_enable"
services = ["api", "web"]
source = "mkam/hello/cts"
enabled = false
terraform_version = "0.15.1"
}
$ consul-terraform-sync task enable kngo_enable
==> Inspecting changes to resource(s) if enabling 'kngo_enable'...
Generating plan that Consul Terraform Sync will use Terraform to execute
Terraform v0.15.1
on linux_amd64
Configuring remote state backend...
Initializing Terraform configuration...
module.kngo_enable.local_file.greeting_services: Refreshing state... [id=adc83b19e793491b1c6ea0fd8b46cd9f32e592fc]
module.kngo_enable.local_file.greeting: Refreshing state... [id=69342c5c39e5ae5f0077aecc32c0f81811fb8193]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# module.kngo_enable.local_file.greeting will be created
...
$ consul-terraform-sync task enable kngo_enable
==> Inspecting changes to resource(s) if enabling 'kngo_enable'...
Generating plan that Consul Terraform Sync will use Terraform to execute
Terraform v0.15.2
on linux_amd64
Configuring remote state backend...
Initializing Terraform configuration...
{"@level":"info","@message":"Terraform 0.15.2","@module":"terraform.ui","@timestamp":"2021-10-12T10:59:32.803143Z","terraform":"0.15.2","type":"version","ui":"0.1.0"}
{"@level":"info","@message":"module.kngo_enable.local_file.greeting_services: Refreshing state... [id=adc83b19e793491b1c6ea0fd8b46cd9f32e592fc]","@module":"terraform.ui","@timestamp":"2021-10-12T10:59:34.302744Z","hook":{"resource":{"addr":"module.kngo_enable.local_file.greeting_services","module":"module.kngo_enable","resource":"local_file.greeting_services","implied_provider":"local","resource_type":"local_file","resource_name":"greeting_services","resource_key":null},"id_key":"id","id_value":"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"},"type":"refresh_start"}
Updated the issue description to reflect our findings:
Describe the bug
When a disabled task is re-enabled through the Enable CLI or CTS is executed in inspect mode, the CLI outputs information from a Terraform Plan to inform the user of the changes that CTS will make when the task becomes enabled.
For the TFC driver, the current CLI output looks different from when it was originally implemented if the task has a Terraform version of
0.15.2
or greater. This current output includes json blobs and is less readable and user-friendly.Workaround: at the bottom of the outputted plan, there should be a URL e.g. "Inspection results can also be viewed at: <url>". This URL will bring you to the TFC UI that will show the plan in a much more readable way.
Sample
Versions
Consul Terraform Sync
Terraform Version
Configuration File(s)
Reminder to redact any sensitive information that may be present in this file
Click to toggle contents of config file
```hcl log_level = "TRACE" working_dir = "build" consul { address = "localhost:8500" } driver "terraform-cloud" { hostname =Steps to Reproduce
consul agent -dev
consul-terraform-sync -config-file=config.hcl
consul services register -name=web -id=web1
consul-terraform-sync task enable task_serv
Expected Behavior
The outputted plan should be human readable so that a user can easily identify what resources are being creates, updated, deleted
Additional Context
Terraform Driver 's output needs to readable both for Terraform versions before and after Terraform v0.15.2.