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

Update Datasources to use last-modified-time instead of request-time in id field

Open peter-dolkens opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe.

If no changes are detected, terraform will run to completion with no user interaction. If there are changes to datasources however, we are required to interact to "approve" the plan/apply.

This can cause issues with some automated and occasionally even manual workflows.

For example - the following is an unnecessary approval step, as nothing has actually changed:

Terraform will perform the following actions:

  # data.octopusdeploy_environments.current will be read during apply
  # (config refers to values not yet known)
 <= data "octopusdeploy_environments" "current"  {
      ~ id   = "Environments 2021-07-15 12:42:35.019170799 +0000 UTC" -> "Environments 2021-07-15 12:43:11.08760703 +0000 UTC"
        name = "test"
        take = 1

        environments {
            allow_dynamic_infrastructure = true
            id                           = "Environments-22"
            name                         = "test"
            sort_order                   = 6
            use_guided_failure           = false
        }
    }

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


Warnings:

- Value for undeclared variable

To see the full warning notes, run Terraform without -compact-warnings.

Do you want to perform these actions in workspace "tst-tnz"?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

Describe the solution you'd like

Instead of returning the timestamp of the request, it would suffice to return the timestamp of the last modification to the datasource (in our case - the last time you added/removed or edited an environment)

This would allow the datasource to change if there are actual changes, but remain static between runs every other time - removing this unnecessary approval step.

Describe alternatives you've considered I'd also consider just removing the ID in this case if possible - it doesn't appear to serve any purpose beyond telling you when the terraform was last applied - which is already captured in your state file.

Additional context n/a

peter-dolkens avatar Jul 15 '21 13:07 peter-dolkens

Which version of Terraform are you using?

jbristowe avatar Jul 31 '21 22:07 jbristowe

This was with 0.13.7

peter-dolkens avatar Aug 01 '21 00:08 peter-dolkens

Upgrading to Terraform 0.14+ should resolve this behaviour.

jbristowe avatar Aug 01 '21 20:08 jbristowe

Noted - that's on our medium-term roadmap, so that should be fine.

peter-dolkens avatar Aug 02 '21 00:08 peter-dolkens

I was not able to reproduce this with latest version of terraform.

I will close this issue, if you can still reproduce it in the latest version, please let us know.

johnsimons avatar Feb 22 '23 04:02 johnsimons