Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot insert new steps into an existing deployment_process correctly #550

Open
veochen-octopus opened this issue Oct 13, 2023 · 2 comments
Labels
area/deployment-processes category/dev-experience Issues about the dev experience of using the provider, writing correct HCL etc category/list-ordering Issues that relate to the order of lists not being deterministic and causing unnecessary state-drift kind/bug Something isn't working

Comments

@veochen-octopus
Copy link
Collaborator

veochen-octopus commented Oct 13, 2023

Describe the bug

Having created a deployment process with two steps, adding a new step in between the existing two steps will cause the new step to become a mixture of its own config + the original 2nd step.

Steps to reproduce

With a terraform file like the following:

resource "octopusdeploy_deployment_process" "example" {
  project_id = "Projects-61"
  step {
    name = "Hello world"
    run_script_action {
      can_be_used_for_project_versioning = false
      condition                          = "Success"
      is_disabled                        = false
      is_required                        = false
      name                               = "Hello world"
      script_syntax                      = "Bash"
      script_body                        = <<-EOT
          echo 'Hello world, using Bash'
          #TODO: Experiment with steps of your own :)
          echo '[Learn more about the types of steps available in Octopus](https://g.octopushq.com/OnboardingAddStepsLearnMore)'
        EOT
      run_on_server                      = true
      sort_order = 1
    }
  }

#   step {
#     name = "Dummy AWS CLI Step"
#     action {
#       name                  = "Dummy AWS CLI STep"
#       action_type           = "Octopus.AwsRunScript"
#       run_on_server         = true
#       environments          = ["Dev"]
#       excluded_environments = []
#       properties = {
#        "OctopusUseBundledTooling"                   = "False"
#        "Octopus.Action.Script.ScriptSource"         = "Inline",
#        "Octopus.Action.Script.Syntax"               = "PowerShell",
#        "Octopus.Action.Aws.AssumeRole"              = "False"
#        "Octopus.Action.AwsAccount.UserInstanceRole" = "True"
#        "Octopus.Action.Aws.Region"                  = "us-east-1"
#        "Octopus.Action.AwsAccount.Variable"         = "DanAWS"
#        "Octopus.Action.Script.ScriptBody"           = "Write-Host \"This is just a test\""
#        }
#        is_disabled = false
#      }
#    }

  step {
    name = "Plan to apply"
    action {
      name        = "Plan to apply"
      action_type = "Octopus.TerraformPlan"
      properties = {
        "Octopus.Action.Package.DownloadOnTentacle"             = "False"
        "Octopus.Action.Package.FeedId"                         = "feeds-builtin"
        "Octopus.Action.Package.PackageId"                      = "hello"
        "Octopus.Action.Terraform.TemplateDirectory"            = "terraform/infrastructure"
        "Octopus.Action.RunOnServer"                            = "False"
        "Octopus.Action.Terraform.PlanJsonOutput"               = "False"
        "Octopus.Action.Script.ScriptSource"                    = "Package"
        "Octopus.Action.Terraform.RunAutomaticFileSubstitution" = "False"
      }
    }
  }  
}
  1. Apply to create the deployment process with 2 steps
  2. Uncomment the 2nd step
  3. Apply to update the deployment process
  4. See error

Expected behavior
Correctly updates the deployment process to have 3 steps that match the config file.

Logs and other supporting information

Error: octopus deploy api returned an error on endpoint /api/Spaces-1/projects/Projects-61/deploymentprocesses - [Providing a package is not valid for inline scripts.]
│
│   with octopusdeploy_deployment_process.example,
│   on test-steps.before.tf line 1, in resource "octopusdeploy_deployment_process" "example":
│    1: resource "octopusdeploy_deployment_process" "example" {

These are the action properties in the new step that TF sends to the server

Octopus.Action.Aws.AssumeRole: False
Octopus.Action.Aws.Region: us-east-1
Octopus.Action.AwsAccount.UserInstanceRole: True
Octopus.Action.AwsAccount.Variable: DanAWS
Octopus.Action.EnabledFeatures: 
Octopus.Action.Package.DownloadOnTentacle: False
Octopus.Action.Package.FeedId: feeds-builtin
Octopus.Action.Package.PackageId: hello
Octopus.Action.RunOnServer: True
Octopus.Action.Script.ScriptBody: Write-Host \"This is just a test\"
Octopus.Action.Script.ScriptSource: Inline
Octopus.Action.Script.Syntax: PowerShell
OctopusUseBundledTooling: False

Environment and versions:

  • OS: Tested on windows
  • Octopus Server Version: Tested on 2023.2 and 2023.3
  • Terraform Version: 1.6.1
  • Octopus Terraform Provider Version: Tested 0.12.7 and 0.12.8
@veochen-octopus veochen-octopus changed the title Support deployment step as its own resource type Cannot add deployment steps out of order Oct 13, 2023
@michelle-luana
Copy link

Another report [Internal Link]

@mjhilton
Copy link
Contributor

Validated as still occurring.

Fixing this will be dependent on fixing the overall step sort order problem, which is dependent on the Terraform SDK -> Terraform Framework migration within the provider. That's on our radar to finish off this year, which should unlock a bunch of extra flexibility in how plan/apply works

@mjhilton mjhilton added category/list-ordering Issues that relate to the order of lists not being deterministic and causing unnecessary state-drift kind/bug Something isn't working category/dev-experience Issues about the dev experience of using the provider, writing correct HCL etc area/deployment-processes labels Sep 20, 2024
@mjhilton mjhilton changed the title Cannot add deployment steps out of order Cannot insert new steps into an existing deployment_process correctly Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deployment-processes category/dev-experience Issues about the dev experience of using the provider, writing correct HCL etc category/list-ordering Issues that relate to the order of lists not being deterministic and causing unnecessary state-drift kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants