Skip to content

Created TFC tasks not using specified Terraform version #792

@mkam

Description

@mkam

Describe the bug

When creating a task where task.terraform_version is specified either through the CLI or API, CTS is not using that version and instead thinks no Terraform version is specified. The created TFC workspace for the task is configured with the latest compatible Terraform version available, which is the default behavior if no Terraform version is given.

Note that task.terraform_version is only supported if using CTS enterprise with the Terraform Cloud driver.

Versions

Consul Terraform Sync

consul-terraform-sync v0.5.2+ent (eab8e1e)
Compatible with Terraform >= 0.13.0, < 1.2.0

Expected Behavior

The Terraform Cloud workspace for the task uses the Terraform version specified by the create task request.

Actual Behavior

The Terraform Cloud workspace for the task uses the Terraform version that CTS defaults to when no version is provided.

Steps to Reproduce

  1. Start CTS enterprise
  2. Create a task with terraform_version via the API or CLI

Additional Context

curl --location --request POST 'http://127.0.0.1:8558/v1/tasks' \
--header 'Content-Type: application/json' \
--data-raw ' {
      "task": {
        "terraform_version": "1.0.5",
        "condition": {
          "services": {
            "names": [
              "api"
            ]
          }
        },
        "module": "mkam/hello/cts",
        "name": "mkam_test_1"
      }
    }'
2022-04-08T12:23:22.835-0500 [TRACE] api.createtask: create task request: request_id=ae78c6e3-5855-84d5-72d2-4ab3c4272004 task_name=mkam_test_1 create_task_request={"task":{"condition":{"services":{"names":["api"]}},"module":"mkam/hello/cts","name":"mkam_test_1","terraform_version":"1.0.5"}}
2022-04-08T12:23:22.835-0500 [TRACE] ctrl: creating new task driver: task_name=mkam_test_1
2022-04-08T12:23:25.988-0500 [INFO]  driver.terraform: retrieved 0 Terraform handlers for task: task_name=mkam_test_1
2022-04-08T12:23:25.988-0500 [TRACE] ctrl: driver created: task_name=mkam_test_1
2022-04-08T12:23:26.937-0500 [INFO]  driver.tfc: creating workspace: org_name=cts-testing workspace_name=mkam_test_1
2022-04-08T12:23:26.938-0500 [DEBUG] driver.tfc: no Terraform version provided, using latest compatible version
2022-04-08T12:23:32.458-0500 [DEBUG] version.terraform: determined latest compatible Terraform version: tf_version=1.1.8 tf_constraint=">= 0.13.0, < 1.2.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenterpriseFeature will be delivered as a part of Enterprise binary

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions