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

use of `run_on_server` and `features` produce a drift in the plan #328

Open oirtemed opened 2 years ago

oirtemed commented 2 years ago

Describe the bug I've tried to replace the property Octopus.Action.RunOnServer with the argument run_on_server after getting the warning below.

╷
│ Warning: "Octopus.Action.RunOnServer" is defined in properties
│ 
│   with octopusdeploy_deployment_process.my_app,
│   on my-app.tf line 128, in resource "octopusdeploy_deployment_process" "my_app":
│  128:         "Octopus.Action.RunOnServer"                                                = "False"
│ 
│ Please update your template to specify "run_on_server" under the action
│ instead.
│ 
│ (and one more similar warning elsewhere)
╵

In a similar way I replaced the Octopus.Action.EnabledFeatures property with the features argument.

After making the changes on the configuration I get a permanent change in the plan (see below).

Steps to reproduce

  1. Create octopusdeploy_deployment_process resource with a step to run a PS script
resource "octopusdeploy_deployment_process" "my_app" {
  project_id = octopusdeploy_project.my_app.id

  step {
    condition           = "Success"
    name                = "StatusCheck"
    package_requirement = "LetOctopusDecide"
    properties = {
      "Octopus.Action.MaxParallelism" = "1"
      "Octopus.Action.TargetRoles"    = "my-app"
    }
    start_trigger = "StartAfterPrevious"
    target_roles = [
      "my-app",
    ]
    window_size = "1"

    run_script_action {
      condition = "Success"
      environments = [
        octopusdeploy_environment.dev.id,
      ]
      features = [
        "Octopus.Features.SubstituteInFiles",
      ]
      is_disabled = false
      is_required = true
      name        = "HTTP - Status check"
      notes       = "check status after deployment"
      properties = {
        "Octopus.Action.Script.ScriptBody"         = file("${path.module}/test_url.ps1")
        "Octopus.Action.Script.ScriptSource"       = "Inline"
        "Octopus.Action.Script.Syntax"             = "PowerShell"
      }
      run_on_server = false
      script_body   = file("${path.module}/test_url.ps1")
      script_source = "Inline"
      script_syntax = "PowerShell"
    }
  }
}
  1. run terraform apply
  2. run terraform plan without making any change in the configuration. This produces the plan output you can find below

Expected behavior Replacing the properties with the arguments should produce a clean plan after applying the change.

Logs and other supporting information terraform plan output after replacing the properties with arguments

      ~ step {
            id                  = "xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx"
            name                = "StatusCheck"
            # (6 unchanged attributes hidden)

          ~ run_script_action {
                id                                 = "xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx"
                name                               = "HTTP - Status check"
              ~ properties                         = {
                  - "Octopus.Action.EnabledFeatures"           = "Octopus.Features.SubstituteInFiles" -> null
                  - "Octopus.Action.RunOnServer"               = "False" -> null
                    # (10 unchanged elements hidden)
                }
                # (13 unchanged attributes hidden)

                # (1 unchanged block hidden)
            }
        }

Environment and versions:

benPearce1 commented 2 months ago

Related to https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy/issues/641