terraform-provider-octopusdeploy icon indicating copy to clipboard operation
terraform-provider-octopusdeploy copied to clipboard

Cannot use a Step ID from a `deployment_process` in a project's `versioning_strategy` in the same module without a circular reference

Open Taha-cmd opened this issue 1 year ago • 1 comments

Describe the bug I want my releases to be versioned the same as a package referenced by a step in my deployment process. We can configure that in the octopusdeploy_project.versioning_strategy.donor_package. However, this requires that the deployment_process already exists, which required the id from the project to be associated with. This causes a circular reference.

Steps to reproduce

terraform {
  required_version = "1.5.7"

  required_providers {
    octopusdeploy = {
      source  = "OctopusDeployLabs/octopusdeploy"
      version = "0.12.7"
    }
  }
}

provider "octopusdeploy" {
  address  = "<REDACTED>"
  api_key  = "<REDACTED>"
  space_id = "<REDACTED>"
}

resource "octopusdeploy_project" "project" {
  lifecycle_id     = "Lifecycles-1402"
  name             = "project"
  project_group_id = "ProjectGroups-1004"

  versioning_strategy {
    # donor_package_step_id = octopusdeploy_deployment_process.process.step[0].id # <- this is a circular reference
    donor_package {
      deployment_action = "Hello World" # <- this step does not exist yet
      package_reference = "Package"
    }
  }
}

resource "octopusdeploy_deployment_process" "process" {
  project_id = octopusdeploy_project.project.id

  step {
    name = "Hello World"

    run_script_action {
      name                               = "Hello World"
      is_disabled                        = false
      is_required                        = true
      script_body                        = "Write-Host 'hello world'"
      script_syntax                      = "PowerShell"
      can_be_used_for_project_versioning = true

      package {
        name                      = "Package"
        feed_id                   = "Feeds-1602"
        package_id                = local.package_id
        acquisition_location      = "Server"
        extract_during_deployment = true
      }
    }
  }
}

locals {
  package_id = "<REDACTED>"
}

Expected behavior I should be able to configure the versioning strategy for green field deployments

Logs and other supporting information Error: 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:

  • OS: Windows
  • Octopus Server Version: 2023.3 Build 13019
  • Terraform Version: 1.5.7
  • Octopus Terraform Provider Version: 0.12.7

Taha-cmd avatar Sep 27 '23 06:09 Taha-cmd

I am having the same issue, is there any progress on this issue?

henbeibi avatar Feb 29 '24 07:02 henbeibi