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

Project scheduled trigger read failure on Terraform Import #849

Open
bec-callow-oct opened this issue Jan 6, 2025 · 1 comment
Open

Comments

@bec-callow-oct
Copy link
Collaborator

bec-callow-oct commented Jan 6, 2025

Describe the bug
A clear and concise description of what the bug is.

Split from issue #740 as this issue requires an unrelated fix.

The provider cannot find project triggers when attempting to import. It fails with the 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. []

When running terraform import, the space ID of the resource is undefined within the resourceProjectScheduledTriggerRead method. We currently use the space ID from the provider as a fallback.

Steps to reproduce

  1. Define a scheduled project trigger
    resource "octopusdeploy_project_scheduled_trigger" "foo" {
      name       = "foo"
      project_id = "Projects-2024"
      space_id   = "Spaces-202"
      run_runbook_action {
        runbook_id             = "Runbooks-865"
        target_environment_ids = ["Environments-366"]
      }
      cron_expression_schedule {
        cron_expression = "0 0 * * *" # daily
      }
    }
  2. Attempt to import
    terraform import octopusdeploy_project_scheduled_trigger.foo ProjectTriggers-103
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

The provider succeeds in discovering the scheduled project trigger

Logs and other supporting information
Add the output of running tf plan or tf apply along with any errors in the Octopus Server logs.

Planning failed. Terraform encountered an error while generating this plan.

╷
│ 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. []
│
│   with octopusdeploy_project_scheduled_trigger.sandbox_cleanup_report,
│   on projects_administration.tf line 108, in resource "octopusdeploy_project_scheduled_trigger" "sandbox_cleanup_report":
│  108: resource "octopusdeploy_project_scheduled_trigger" "sandbox_cleanup_report" {
│
╵

Screenshots
If applicable, add screenshots to help explain your problem.

N/A

Environment and versions:

  • OS: Linux, OSX
  • Octopus Server Version: 2024.3.10026
  • Terraform Version: 1.8.2
  • Octopus Terraform Provider Version: 0.18.1

Additional context
Add any other context about the problem here.

Note copied from issue #740 : It doesn't appear newer versions of the provider have touched this resource but I have not upgraded as the migration to tenant_project resources is a breaking change which is going to require a fair amount of work

@bec-callow-oct
Copy link
Collaborator Author

bec-callow-oct commented Jan 6, 2025

We should be able to resolve this issue by handling imports in a similar way to how they are handled for environments. This requires us to migrate this resource to use terraform-plugin-framework

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant