OctopusDeployLabs / terraform-provider-octopusdeploy

Terraform Provider for Octopus Deploy :octopus:
https://registry.terraform.io/providers/OctopusDeployLabs/octopusdeploy
Mozilla Public License 2.0
81 stars 67 forks source link

SpaceId on octopusdeploy_variable resource is not honoured during create #771

Closed benPearce1 closed 1 month ago

benPearce1 commented 1 month ago

Describe the bug A clear and concise description of what the bug is.

Steps to reproduce Using the following Terraform config

terraform {
  required_providers {
    octopusdeploy = {
        source = "OctopusDeployLabs/octopusdeploy"
        version = "0.30.0"
    }
  }
}

provider "octopusdeploy" {
  address = "http://localhost:8066"
  api_key = "API-apikey"
}

resource "octopusdeploy_space" "space" {
  name = "test-space"
  space_managers_teams = ["teams-managers", "teams-administrators"]
}

resource "octopusdeploy_library_variable_set" "octopus_library_variable_set" {
  name = "Test-lvs-terraform"
  description = "Test variable set"
  space_id = octopusdeploy_space.space.id
}

resource "octopusdeploy_variable" "string" {
  owner_id = octopusdeploy_library_variable_set.octopus_library_variable_set.id
  space_id = octopusdeploy_space.space.id
  type = "String"
  name = "stringvar"
  value = "value2"
}

Run terraform apply

On apply, an error will occur and the variable will not be successfully created.

Expected behavior The expected behaviour is that a variable will be created in the owning library variable set or project

Logs and other supporting information

│ Error: create variable failed
│ 
│   with octopusdeploy_variable.string,
│   on main.tf line 31, in resource "octopusdeploy_variable" "string":
│   31: resource "octopusdeploy_variable" "string" {
│ 
│ Octopus API error: Resource is not found or it doesn't exist in the current space context. Please contact your administrator for more information. [] 

Environment and versions:

Additional context Add any other context about the problem here.