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

octopusdeploy_tenant_project import documentation #782

Open stalmok opened 6 days ago

stalmok commented 6 days ago

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

I can't figure out what octopusdeploy_tenant_project ID should be used for importing:

import {
  for_each = local.tenants

  to = octopusdeploy_tenant_project.main[each.key]
  id = ???
}

Describe the solution you'd like Maybe add import section to documentation?

stalmok commented 4 days ago

I've identified that the ID format for importing an octopusdeploy_tenant_project resource is "space-id:tenant-id:project-id", but unfortunately, the import doesn't work as expected.

Steps I Took:

  1. Manual Import Attempt (I'm certain that the configuration exists):

    │ Error: Configuration for import target does not exist
    │
    │ The configuration for the given import octopusdeploy_tenant_project.project["tenant-id"] does not exist. All target instances must have an associated configuration to be imported.
  2. Using Terraform's import Command (I'm certain that project_id and tenant_id are defined):

    # octopusdeploy_tenant_project.project["tenant-id"] must be replaced
    # (imported from "Spaces-1:Tenants-1163:Projects-41")
    # Warning: this will destroy the imported resource
    -/+ resource "octopusdeploy_tenant_project" "platform" {
         environment_ids = [
             "Environments-2",
             "Environments-3",
             "Environments-4",
         ]
       ~ id              = "Spaces-1:Tenants-1163:Projects-41" -> (known after apply)
       + project_id      = "Projects-41" # forces replacement
       ~ space_id        = "Spaces-1" -> (known after apply)
       + tenant_id       = "Tenants-1163" # forces replacement
     }

Issue:

Even though the IDs are correctly formatted and the configurations exist, the import fails with the error message: "Configuration for import target does not exist."

When using the Terraform import command, it seems to recognize the IDs but still attempts to force replacement of the resource, which is unexpected behavior.