leg100/otf

Bug: Issue creating variable sets through API / tfe provider

Closed this issue · 1 comments

adamlc commented

Thank you for all your work on variable sets, its really helped with our setup workflow significantly.

We're now running 38 workspaces migrated from TF Cloud!

Anyway, I did have an issue when creating variable sets through the TFE terraform provider on OTF 0.1.9.

terraform {
  required_providers {
    tfe = {
      version = "~> 0.48.0"
    }
  }
}

provider "tfe" {
  hostname = "..."
  organization = "..."
}

resource "tfe_variable_set" "test" {
  name          = "Test Varset"
  description   = "Some description."
}

resource "tfe_variable" "test-a" {
  key             = "seperate_variable"
  value           = "my_value_name"
  category        = "terraform"
  description     = "a useful description"
  variable_set_id = tfe_variable_set.test.id
}

resource "tfe_variable" "test-b" {
  key             = "another_variable"
  value           = "my_value_name"
  category        = "env"
  description     = "an environment variable"
  variable_set_id = tfe_variable_set.test.id
}

Producing the following plan:

terraform plan -out="plan.tfplan"

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:

  # tfe_variable.test-a will be created
  + resource "tfe_variable" "test-a" {
      + category        = "terraform"
      + description     = "a useful description"
      + hcl             = false
      + id              = (known after apply)
      + key             = "seperate_variable"
      + readable_value  = "my_value_name"
      + sensitive       = false
      + value           = (sensitive value)
      + variable_set_id = (known after apply)
    }

  # tfe_variable.test-b will be created
  + resource "tfe_variable" "test-b" {
      + category        = "env"
      + description     = "an environment variable"
      + hcl             = false
      + id              = (known after apply)
      + key             = "another_variable"
      + readable_value  = "my_value_name"
      + sensitive       = false
      + value           = (sensitive value)
      + variable_set_id = (known after apply)
    }

  # tfe_variable_set.test will be created
  + resource "tfe_variable_set" "test" {
      + description   = "Some description."
      + global        = false
      + id            = (known after apply)
      + name          = "Test Varset"
      + organization  = (known after apply)
      + workspace_ids = (known after apply)
    }

Plan: 3 to add, 0 to change, 0 to destroy.

But when I apply the plan the variable set itself gets created. But the variables hang eventually failing with a interface pointer error.

terraform apply "plan.tfplan"
tfe_variable_set.test: Creating...
tfe_variable_set.test: Creation complete after 1s [id=varset-iQaii6nhzbOCoMKW]
tfe_variable.test-a: Creating...
tfe_variable.test-b: Creating...
tfe_variable.test-b: Still creating... [10s elapsed]
tfe_variable.test-a: Still creating... [10s elapsed]
tfe_variable.test-b: Still creating... [20s elapsed]
tfe_variable.test-a: Still creating... [20s elapsed]
tfe_variable.test-b: Still creating... [30s elapsed]
tfe_variable.test-a: Still creating... [30s elapsed]
tfe_variable.test-b: Still creating... [40s elapsed]
tfe_variable.test-a: Still creating... [40s elapsed]
tfe_variable.test-b: Still creating... [50s elapsed]
tfe_variable.test-a: Still creating... [50s elapsed]
tfe_variable.test-b: Still creating... [1m0s elapsed]
tfe_variable.test-a: Still creating... [1m0s elapsed]
tfe_variable.test-b: Still creating... [1m10s elapsed]
tfe_variable.test-a: Still creating... [1m10s elapsed]
tfe_variable.test-b: Still creating... [1m20s elapsed]
tfe_variable.test-a: Still creating... [1m20s elapsed]
tfe_variable.test-b: Still creating... [1m30s elapsed]
tfe_variable.test-a: Still creating... [1m30s elapsed]
tfe_variable.test-b: Still creating... [1m40s elapsed]
tfe_variable.test-a: Still creating... [1m40s elapsed]
tfe_variable.test-b: Still creating... [1m50s elapsed]
tfe_variable.test-a: Still creating... [1m50s elapsed]
tfe_variable.test-b: Still creating... [2m0s elapsed]
tfe_variable.test-a: Still creating... [2m0s elapsed]
tfe_variable.test-b: Still creating... [2m10s elapsed]
tfe_variable.test-a: Still creating... [2m10s elapsed]
tfe_variable.test-b: Still creating... [2m20s elapsed]
tfe_variable.test-a: Still creating... [2m20s elapsed]
tfe_variable.test-b: Still creating... [2m30s elapsed]
tfe_variable.test-a: Still creating... [2m30s elapsed]
tfe_variable.test-b: Still creating... [2m40s elapsed]
tfe_variable.test-a: Still creating... [2m40s elapsed]
tfe_variable.test-b: Still creating... [2m50s elapsed]
tfe_variable.test-a: Still creating... [2m50s elapsed]
tfe_variable.test-b: Still creating... [3m0s elapsed]
tfe_variable.test-a: Still creating... [3m0s elapsed]
tfe_variable.test-b: Still creating... [3m10s elapsed]
tfe_variable.test-a: Still creating... [3m10s elapsed]
tfe_variable.test-b: Still creating... [3m20s elapsed]
tfe_variable.test-a: Still creating... [3m20s elapsed]
tfe_variable.test-b: Still creating... [3m30s elapsed]
tfe_variable.test-a: Still creating... [3m30s elapsed]
tfe_variable.test-b: Still creating... [3m40s elapsed]
tfe_variable.test-a: Still creating... [3m40s elapsed]
tfe_variable.test-b: Still creating... [3m50s elapsed]
tfe_variable.test-a: Still creating... [3m50s elapsed]
tfe_variable.test-b: Still creating... [4m0s elapsed]
tfe_variable.test-a: Still creating... [4m0s elapsed]
tfe_variable.test-b: Still creating... [4m10s elapsed]
tfe_variable.test-a: Still creating... [4m10s elapsed]
tfe_variable.test-b: Still creating... [4m20s elapsed]
tfe_variable.test-a: Still creating... [4m20s elapsed]
tfe_variable.test-b: Still creating... [4m30s elapsed]
tfe_variable.test-a: Still creating... [4m30s elapsed]
tfe_variable.test-b: Still creating... [4m40s elapsed]
tfe_variable.test-a: Still creating... [4m40s elapsed]
tfe_variable.test-b: Still creating... [4m50s elapsed]
tfe_variable.test-a: Still creating... [4m50s elapsed]
tfe_variable.test-b: Still creating... [5m0s elapsed]
tfe_variable.test-a: Still creating... [5m0s elapsed]
tfe_variable.test-b: Still creating... [5m10s elapsed]
tfe_variable.test-a: Still creating... [5m10s elapsed]
tfe_variable.test-b: Still creating... [5m20s elapsed]
tfe_variable.test-a: Still creating... [5m20s elapsed]
tfe_variable.test-b: Still creating... [5m30s elapsed]
tfe_variable.test-a: Still creating... [5m30s elapsed]
tfe_variable.test-b: Still creating... [5m40s elapsed]
tfe_variable.test-a: Still creating... [5m40s elapsed]
tfe_variable.test-b: Still creating... [5m50s elapsed]
tfe_variable.test-a: Still creating... [5m50s elapsed]
tfe_variable.test-b: Still creating... [6m0s elapsed]
tfe_variable.test-a: Still creating... [6m0s elapsed]
tfe_variable.test-b: Still creating... [6m10s elapsed]
tfe_variable.test-a: Still creating... [6m10s elapsed]
tfe_variable.test-b: Still creating... [6m20s elapsed]
╷
│ Error: Error creating variable
│
│   with tfe_variable.test-a,
│   on main.tf line 21, in resource "tfe_variable" "test-a":
│   21: resource "tfe_variable" "test-a" {
│
│ Couldn't create terraform variable seperate_variable: Internal Server Error
│
│ schema: interface must be a pointer to struct
╵
╷
│ Error: Error creating variable
│
│   with tfe_variable.test-b,
│   on main.tf line 29, in resource "tfe_variable" "test-b":
│   29: resource "tfe_variable" "test-b" {
│
│ Couldn't create env variable another_variable: Internal Server Error
│
│ schema: interface must be a pointer to struct

Thanks!

leg100 commented

Hello. Looks like the API endpoints for variable set variables were never implemented properly, and certainly not tested. I'll work on a fix shortly.